-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Closed
Labels
Description
Bug report
What is the current behavior?
In packages with type: "module", webpack fails to parse and replace require.context() expressions.
If the current behavior is a bug, please provide the steps to reproduce.
- Clone https://github.com/tavoyne/webpack-2ece8c.
- Run
yarn webpack --mode=production. - Inspect the
dist/main.jsfile and notice that therequire.context()expression is still present. - (Remove
type: "module"from thepackage.jsonfile.) - (Inspect the
dist/main.jsfile again and notice how therequire.context()expression was successfully replaced.)
What is the expected behavior?
The replacement to be successful at step (3).
As require is not available in ESM environments, it could be called import.context in order to avoid confusion.
Other relevant information:
webpack version: 5.68.0
Node.js version: 17.4.0
Operating System: MacOS
Additional tools: N/A
Reactions are currently unavailable