Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to node_modules should trigger recompilation #186

Closed
gaearon opened this issue Jul 25, 2016 · 6 comments
Closed

Changes to node_modules should trigger recompilation #186

gaearon opened this issue Jul 25, 2016 · 6 comments

Comments

@gaearon
Copy link
Contributor

gaearon commented Jul 25, 2016

  1. Add import 'react-router' to index.js
  2. See module not found error
  3. npm install react-router
  4. Still see module not found error
  5. Press “save” in index.js
  6. Now it compiled successfully!

Steps 4 and 5 should not be there. We should find a way to tell webpack that node_modules have changed, and it’s worth trying to recompile.

Ideally we should not have situations where user is forced to stop the bundler and run npm start again. I remember having such issues when switching branches. Hopefully fixing the above use case should be enough, but if you’re familiar with other cases where a restart is required, please write in this thread.

@lacker
Copy link
Contributor

lacker commented Jul 26, 2016

Do you mean npm install react-router --save? I suspect there are performance issues with watching the whole node_modules tree - React Native runs into that - but just watching package.json seems like it should be efficient. But it wouldn't catch it if you just npm install react-router.

@eanplatter
Copy link
Contributor

@lacker yes you have to restart when you do npm install react-router --save which like you said wouldn't be an issue to watch the package.json.

While I think installing a node module without --save it still seems like a janky experience regardless. Perhaps there is a way you can check if webpack is throwing aModule not found error and then check the node_modules rather than having to watch them directly?

@mxstbr
Copy link
Contributor

mxstbr commented Jul 26, 2016

What about using this? https://github.com/ericclemmons/npm-install-webpack-plugin I think that solves our problem.

@insin
Copy link
Contributor

insin commented Jul 26, 2016

@mxstbr beat me to it, npm-install-webpack-plugin is DX gold /cc @ericclemmons

@eanplatter
Copy link
Contributor

That's a pretty slick plugin, #212 is an attempt at implementing it.

@taion
Copy link

taion commented Jul 26, 2016

I have a vague recollection that this used to "just work" with npm2, but that it stopped working after I upgraded to npm3.

Didn't have a chance to look into that, though.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants