Does not work with npm link
See original GitHub issueI’m not sure if this problem is coming from this loader or webpack or from node itself.
I’m developing a package having peerDependencies, so I’ve npm link
ed it to my application, that means that when I cd into my application’s node_modules
I see a symlink my-package
-> /real/path/to/my-package
.
I’m using webpack2 and my resolve.modules looks like this:
resolve: {
extensions: ['.js', '.jsx', '.coffee'],
modules: [
path.join(__dirname, "src"),
path.join(__dirname, "node_modules"), // this was the 'fallback' option (for npm link-ed packages)
],
So npm link-ed packages should be correctly resolved.
This is the configuration for this loader:
{
test: /\.js?$/,
include: [
path.resolve(__dirname, node_modules/my-package)
],
loader: "source-map-loader",
enforce: "pre"
}
but things don’t work.
Following all the options I’ve tried to pass to include
:
path.resolve(__dirname, node_modules/my-package)
doesn’t work- explicitly pass a relative path string
./node_modules/my-package
: doesn’t work - explicitly pass an absolute path string
/real/path/to/my-package
: works - remove the
include
: works - using
fs.realpathSync('./node_modules/my-package')
: works
By removing the include
option it works but the loader will look everywhere, and as advised in the doc it’s not very efficient, but it works.
I have seen #14 that links to a webpack issue but it seems that old issue has been resolved in webpack2 (the one I’m using).
So I’m a bit confused about this issue, how I’m supposed to correctly setup the include path and from where exactly this issue is coming from?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:7 (1 by maintainers)
Top GitHub Comments
I kinda of make it work with
and using
devtool: "#inline-source-map",
@LeonardoGentile Are you sure “node_modules” is part of the path webpack is using to include your module?
Since your using npm link it’s likely webpack is using the resolved symlink instead of the link itself (ie:
./node_modules/my_package
).Could you try to remove the include option and use the main file of your package for the test regex ? For example: test: /
my-package-main\.js/
Just to be sure.