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

Use relative node_modules path for webpack resolve.modules config #166

Closed
wants to merge 1 commit into from

Conversation

nrako
Copy link

@nrako nrako commented Mar 9, 2017

Yarn (and NPM3+) try to flatten the node_modules directory, but when different versions of the same package are required Yarn (and NPM as well) will fallback to a nested structure.

If node_modules is set as an absolute path, webpack will only search in that directory, ignoring a potential nested node packages.

A relative path will be scanned similarly to how Node scans for node_modules, by looking through the current directory as well as it's ancestors (i.e. ./node_modules, ../node_modules, and on).

resolve.modules defaults to:

modules: ["node_modules"]

Ref: https://webpack.js.org/configuration/resolve/#resolve-modules

@nrako nrako force-pushed the webpack_resolve_modules branch from e407ec3 to 7cf0b9c Compare March 9, 2017 19:47
@gauravtiwari gauravtiwari mentioned this pull request Mar 18, 2017
10 tasks
@gauravtiwari
Copy link
Member

We can close this one @nrako #153 is merged

@dhh dhh closed this Mar 23, 2017
@nrako
Copy link
Author

nrako commented Mar 26, 2017

@gauravtiwari I don't think so, how is #153 closing this?

Sure #153 moved quite a lot of stuff around but I don't believe it fixed what that PR intended to.

This line:
https://github.com/gauravtiwari/webpacker/blob/d7278d28a3e8f66ec7e5df6205e37550a68f0eb6/lib/install/config/webpack/shared.js#L44

Should be path.node_modules, without the resolve(), otherwise webpack receive an absolute path and won't lookup modules relatively the way it should.

@nrako
Copy link
Author

nrako commented Mar 26, 2017

I would also just use 'node_modules', instead of path.node_modules IMHO this is useless verbosity.

@gauravtiwari
Copy link
Member

Ohh shoot, confused it with resolveLoader. Perhaps, you could open this one up again?

@nrako
Copy link
Author

nrako commented Mar 26, 2017

@gauravtiwari - sure. What do you think of also removing node_modules for the paths.yml file?

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

Successfully merging this pull request may close these issues.

3 participants