Ben Davis
Ben Davis

Reputation: 13830

Snowpack dev server is not recompiling files in node_modules when changed

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?

Upvotes: 9

Views: 1147

Answers (2)

Shubham Verma
Shubham Verma

Reputation: 5054

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.

Upvotes: 2

Quintin Henn
Quintin Henn

Reputation: 91

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.

Upvotes: 3

Related Questions