webpack-contrib / install-webpack-plugin

Speed up development by automatically installing & saving dependencies with Webpack.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tries to install relative entry in cwd

insin opened this issue · comments

With webpack config below, where app.js is in process.cwd():

entry:
   [ 'C:\\Users\\Jonny\\AppData\\Roaming\\npm\\node_modules\\nwb\\node_modules\\eventsource-polyfill\\dist\\browserify-eventsource.js',
     'C:\\Users\\Jonny\\AppData\\Roaming\\npm\\node_modules\\nwb\\node_modules\\webpack-hot-middleware\\client.js',
     'app.js' ],

Result:

webpack building...
Installing app.js...
npm WARN package.json serve-react@1.0.0 No description
npm WARN package.json serve-react@1.0.0 No repository field.
npm WARN package.json serve-react@1.0.0 No README data
npm ERR! not a package C:\Users\Jonny\tmp\serve-react\app.js
npm ERR! addLocal Could not install C:\Users\Jonny\tmp\serve-react\app.js
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Jonny\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "app.js" "--save"

Works fine if I path.resolve() the entry so it gets an absolute path instead - I'm going to change my own code to do this right now, but thought this was worth reporting.

@insin Good catch! I don't have a Window machine, so I had no idea :)

I'm not sure which part is trying to install app.js. If it's ./app.js, it works fine?

I wonder if I should remove this chunk:

https://github.com/ericclemmons/npm-install-webpack-plugin/blob/7649f30743038ef143ecf0c1cba431ce54416f6e/src/installer.js#L63-L66

My thinking is:

  • If the module is require.resolveable, then it exists & shouldn't be installed.
  • However, modules missing from package.json should be.
  • But this is a problem, because app.js would not exist in `package.json, so it'd try to be installed anyway.
  • Some NPM packages have .js or similar in their package name (fewer nowadays), so the extension may not be a valid signature for determining if something's a module or not.

So, should this just be a caveat?

Dunno what to do...

I think it should just be a caveat that people should be using relative (or absolute) entry paths for local files. That's what the Webpack docs do.

True, it's even listed here as relative:

https://webpack.github.io/docs/configuration.html#entry