liady / webpack-node-externals

Easily exclude node modules in Webpack
MIT License
1.3k stars 62 forks source link

"Why is not bundling node_modules a good thing" info not correct? #55

Closed stevemao closed 4 years ago

stevemao commented 6 years ago

It goes against the entire npm dependencies management. If you're using Lodash, and the consumer of your library also has the same Lodash dependency, npm makes sure that it will be added only once. But bundling Lodash in your library will actually make it included twice, since npm is no longer managing this dependency.

I'm not sure if this is correct. Webpack will only bundle it once if within the same version range. I think another reason to use this module is some modules might use binary. Some might use unconventional way to load modules. Some might use fs with relative paths.

dmngu9 commented 5 years ago

Hi steve. Any update?

stevemao commented 5 years ago

We shouldn't bundle node_modules, but the reason in README is wrong.

liady commented 4 years ago

Hi, if still relevant - when building a library for npm (or for Node environment), there is actually no need to bundle its dependencies. Since it will run in Node, it can just require its dependencies (without bundling). The purpose of this library is to allow running Webpack on the source code - while keeping the dependencies unbundled.