Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We used to honor
NODE_PATH
because it provides a relatively convenient way to allow absolute imports for people who need them:NODE_PATH=src npm start
.However this backfired with #1023 and #815.
The best analysis is in #1023 (comment).
Sometimes, a module (which may be inside a dependency) may depend on Node core modules like
events
. In this case Webpack attempts to shim it with node-libs-browser. However it only attempts to shim it if it can't resolve the module name using the regular mechanism. The problem is that some Linux distributions include Node sources intoNODE_PATH
. Therefore, since we honorNODE_PATH
, Webpack findsevents
in Node.js sources on those systems, and thus doesn't attempt to shim it. As a result you get the latest version from Node.js itself which is likely incompatible with the browsers.To fix this, we need a way to not allow Node.js core modules to resolve to Node.js sources even if they exist in
NODE_PATH
. I don't see any easy way to do this. However we can sidestep the issue by not respecting absolute paths inNODE_PATH
. The only reason we addedNODE_PATH
support is for absolute imports (NODE_PATH=src npm start
), whereNODE_PATH
itself is relative. Any other uses of it are inherently dangerous (and won't work across systems anyway). So I think it should be safe to just stop honoring absoluteNODE_PATH
altogether, thus solving both issues.It is technically a breaking change but for a use case we never intended to support. I have a hard time believing anyone could've intentionally relied on this, and if it breaks anyone, it will more likely uncover a bug. Therefore I think this is safe to go in 0.8.x, especially given that it fixes more egregious bugs that have been affecting people for months, and 0.8 has been out for just four days.