question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

webpack 4.45.0 falls to build with ModuleScopePlugin

See original GitHub issue

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:

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
alexander-akaitcommented, Jan 12, 2021

Fixed, please update to latest version (v4)

1reaction
sokracommented, Jan 11, 2021

Ok I think I know the issue… Working on a fix

Read more comments on GitHub >

github_iconTop Results From Across the Web

4.45.0 - webpack - npm
Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand.
Read more >
Upgrade to Webpack 5 failing - node.js - Stack Overflow
I am attempting upgrade to Webpack 4 to Webpack 5. ... const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin'); const ...
Read more >
To v5 from v4 - webpack
This guide aims to help you migrating to webpack 5 when using webpack directly. If you are using a higher level tool to...
Read more >
react-dev-utils | Yarn - Package Manager
This package includes some utilities used by Create React App. Please refer to its documentation: Getting Started – How to create a new...
Read more >
webpack - npm Package Health Analysis - Snyk
Learn more about webpack: package health score, popularity, security, maintenance, versions and more.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found