Skip to content

Unexpected behavior with linked NPM modules #985

@ooflorent

Description

@ooflorent

tl;dr

Webpack should produce the same build whether a module is linked or not.

In depth

Considering the following dependency trees:

project@1.0.0
├── babel-runtime@5.1.9
└── sub-project@1.0.0
sub-project@1.0.0
└── babel-runtime@5.1.9

Notice: NPM does not include babel-runtime under sub-project when npm list is called from project.

Webpack builds something link:

[0] multi main 52 bytes {0} [built]
[1] ./index.js 2.08 kB {0} [built]
[2] ./~/babel-runtime/helpers/interop-require-wildcard.js 148 bytes {0} [built]
[3] ./~/sub-project/index.js 2.46 kB {0} [built]

If we run npm link sub-project we obtain the following tree:

project@1.0.0
├── babel-runtime@5.1.9
└── sub-project@1.0.0 -> /Users/fc/Development/sub-project

Notice: babel-runtime still doesn't appear under sub-project.

But building the project again will duplicate its dependencies:

[0] multi main 52 bytes {0} [built]
[1] ./index.js 2.08 kB {0} [built]
[2] ./~/babel-runtime/helpers/interop-require-wildcard.js 148 bytes {0} [built]
[3] /Users/fc/Development/sub-project/index.js 2.46 kB {0} [built]
[4] /Users/fc/Development/sub-project/~/babel-runtime/helpers/interop-require-wildcard.js 148 bytes {0} [built]

Using resolve.root or changing the resolve scope of loaders do not change anything.

Expectations

It would link to be able the link my in-development modules into my project using npm link without having to tweak the webpack config.

The real problem isn't the build size but the unexpected behaviors raised but duplicated dependencies.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions