Snowpack dev server is not recompiling files in node_modules when changed
Asked Answered
A

2

9

I have a snowpack project that I started from the blank template. My index.js file calls a function from another module I'm developing that I have installed using npm link.

When I change a file in the other module, it doesn't get updated in snowpack. Even when I restart the dev server, it doesn't update. I have to restart snowpack with the --reload argument to clear the cache.

How do I make sure changes to files in node_modules get recognized by snowpack so that they are rebuilt?

Aeromechanic answered 20/11, 2020 at 2:47 Comment(0)
N
3

Unfortunately the way Snowpack works is it caches the node_modules dependencies and rarely rebuilds them.

In the documentation section Using NPM Dependencies

  1. Because your dependencies rarely change, Snowpack rarely needs to rebuild them.

Each build tool has its pros and cons, and Snowpack is not going to work for you, in this instance where you still need to update the linked dependency.

You might want to look at other build tools like Webpack. Here is stack overflow answer on correctly configure Webpack to watch only for the linked dependency.

It seems that even the Parcel 2 doesn't detect changes in linked dependencies.

Natalee answered 14/7, 2021 at 5:31 Comment(0)
C
2

You can delete .cache/snowpack inside node_modules folder for rebuilding. More concise you can delete specific folder which you want to make it rebuild, This is only hack I found that works.

Correna answered 19/9, 2021 at 9:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.