Skip to content

webpack 4.45.0 falls to build with ModuleScopePlugin #12386

@AlbertXiao1994

Description

@AlbertXiao1994

Bug report

What is the current behavior?
In webpack v4.45.0,When I build a project with ModuleScopePlugin,it throws an error:ModuleNotFoundError: Module not found: Error: You attempted to import /Users/workspace/node_modules/_events@3.2.0@events/events.js which falls outside of the project src/ directory. Relative imports outside of src/ are not supported. You can either move it inside src/, or add a symlink to it from project's node_modules/.

This is error stack:

at factory.create (/Users/worspace/node_modules/_webpack@4.45.0@webpack/lib/Compilation.js:925:10)
at factory (/Users/worspace/node_modules/_webpack@4.45.0@webpack/lib/NormalModuleFactory.js:401:22)
at resolver (/Users/worspace/node_modules/_webpack@4.45.0@webpack/lib/NormalModuleFactory.js:130:21)
at asyncLib.parallel (/Users/worspace/node_modules/_webpack@4.45.0@webpack/lib/NormalModuleFactory.js:224:22)
at /Users/worspace/node_modules/_neo-async@2.6.2@neo-async/async.js:2830:7
at /Users/worspace/node_modules/_neo-async@2.6.2@neo-async/async.js:6877:13

But it works well in webpack v4.44.2.

If the current behavior is a bug, please provide the steps to reproduce.
I build my app with following config:

// webpack.prod.js
resolve: {
      plugins: [
        new ModuleScopePlugin(join(process.cwd(), 'src'), [join(process.cwd(), 'package.json')]),
      ],
    },

What is the expected behavior?
It builds successfully.

Other relevant information:
webpack version: 4.45.0
Node.js version: 10.23.0
Operating System: macOS Big Sur 11.1
Additional tools:

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