fix: re-export ModuleNotFoundError from lib/ModuleNotFoundError#20988
Conversation
Some old plugins use `require("webpack/lib/ModuleNotFoundError")` directly.
Add a re-export at the legacy path, mirroring how `lib/WebpackError.js`
re-exports `./errors/WebpackError`. Marked with a TODO to remove in webpack@6.
Refs #20985
🦋 Changeset detectedLatest commit: 3f91b4d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
This PR is packaged and the instant preview is available (a39f2d3). Install it locally:
npm i -D webpack@https://pkg.pr.new/webpack@a39f2d3
yarn add -D webpack@https://pkg.pr.new/webpack@a39f2d3
pnpm add -D webpack@https://pkg.pr.new/webpack@a39f2d3 |
There was a problem hiding this comment.
Pull request overview
This PR restores backward compatibility for legacy plugins that deep-import ModuleNotFoundError via require("webpack/lib/ModuleNotFoundError") by reintroducing that path as a thin re-export of the canonical implementation in lib/errors/ModuleNotFoundError.
Changes:
- Add
lib/ModuleNotFoundError.jsas a legacy re-export shim (with a TODO to remove in webpack 6). - Add a changeset to publish the compatibility fix as a patch release.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
lib/ModuleNotFoundError.js |
Re-exports ./errors/ModuleNotFoundError to restore the removed deep import path used by older plugins. |
.changeset/reexport-module-not-found-error.md |
Announces the patch-level backward-compatibility re-export and its planned removal in webpack 6. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #20988 +/- ##
=======================================
Coverage 90.94% 90.94%
=======================================
Files 573 573
Lines 58938 58938
Branches 15889 15889
=======================================
Hits 53603 53603
Misses 5335 5335
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Merging this PR will degrade performance by 31.24%
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
…k 5.107.0 compat (#35753) ## Current Behavior All webpack-based React Module Federation e2e tests started failing on 2026-05-20. Webpack 5.107.0 (published earlier today) reorganized its internal `lib/` directory into subdirectories — e.g. `lib/ModuleNotFoundError.js` moved to `lib/errors/ModuleNotFoundError.js`, `lib/DllPlugin.js` moved to `lib/dll/DllPlugin.js`, etc. `@module-federation/enhanced` (which our generators wire up for webpack-based host/remote apps) deep-imports `require('webpack/lib/ModuleNotFoundError')`, which now throws `MODULE_NOT_FOUND` and aborts every webpack-based MF build/serve in our react e2e suite. Sample failure: ``` NX Cannot find module 'webpack/lib/ModuleNotFoundError' Require stack: - node_modules/@module-federation/enhanced/dist/src/lib/sharing/resolveMatchedConfigs.js - node_modules/@module-federation/enhanced/dist/src/lib/sharing/ConsumeSharedPlugin.js - ... - node_modules/@nx/module-federation/src/with-module-federation/webpack/with-module-federation.js ``` This is upstream's bug, not ours: - webpack/webpack#20985 — closed by webpack maintainer pointing at module-federation - module-federation/core#4747 — open issue for module-federation to stop using private webpack APIs - webpack/webpack#20988 — adds back a `lib/ModuleNotFoundError` compat shim (merged, awaiting a webpack patch release) Even after the shim release lands, other deep imports may still be broken, so we want to fully decouple our CI from this until both ecosystems re-sync. Angular MF goes through the same `@module-federation/enhanced/webpack` code path and would theoretically fail too, but only react tests were observed failing in CI. The angular suites are left enabled so we get a real signal if/when they hit the same issue. ## Expected Behavior CI passes. Webpack-based react MF e2e suites are temporarily skipped with `describe.skip` and a TODO comment linking the upstream tracking issues. Rspack-based MF e2e tests and angular MF e2e tests are untouched and continue to run. Skipped suites: - `e2e/react/src/module-federation/core-webpack-basic-host-remote-generation.test.ts` - `e2e/react/src/module-federation/core-webpack-basic-playwright.test.ts` - `e2e/react/src/module-federation/core-webpack-name-and-root.test.ts` - `e2e/react/src/module-federation/core-webpack-query-params.test.ts` - `e2e/react/src/module-federation/core-webpack-ssr.test.ts` - `e2e/react/src/module-federation/dynamic-federation.webpack.test.ts` - `e2e/react/src/module-federation/federate-module.webpack.test.ts` - `e2e/react/src/module-federation/independent-deployability.webpack.test.ts` - `e2e/react/src/module-federation/misc-rspack-interoperability.test.ts` (both scenarios still build with webpack on one side) ## Related Issue(s) Tracking upstream: - webpack/webpack#20985 - module-federation/core#4747 - webpack/webpack#20988 --------- Co-authored-by: nx-cloud[bot] <71083854+nx-cloud[bot]@users.noreply.github.com> Co-authored-by: FrozenPandaz <FrozenPandaz@users.noreply.github.com>
…bpack 5.107.1 fix is live) (#35764) ## Current Behavior PR #35753 skipped 9 webpack-based React Module Federation e2e suites because webpack 5.107.0 (published 2026-05-20) reorganized its `lib/` directory and removed `lib/ModuleNotFoundError.js`, which `@module-federation/enhanced` deep-imports. Every webpack-based MF build/serve in the affected suites was failing with `Cannot find module 'webpack/lib/ModuleNotFoundError'`. ## Expected Behavior webpack 5.107.1 (published 2026-05-21) restored the path as a backward-compat shim — `lib/ModuleNotFoundError.js` now re-exports from `./errors/ModuleNotFoundError`. Verified locally that all 21 `webpack/lib/*` paths used by `@module-federation/enhanced` 2.4.0 / 2.5.0 now resolve in 5.107.1. This PR removes the `describe.skip` + TODO + `// eslint-disable-next-line jest/no-disabled-tests` lines from the 9 affected files, re-enabling: - `e2e/react/src/module-federation/core-webpack-basic-host-remote-generation.test.ts` - `e2e/react/src/module-federation/core-webpack-basic-playwright.test.ts` - `e2e/react/src/module-federation/core-webpack-name-and-root.test.ts` - `e2e/react/src/module-federation/core-webpack-query-params.test.ts` - `e2e/react/src/module-federation/core-webpack-ssr.test.ts` - `e2e/react/src/module-federation/dynamic-federation.webpack.test.ts` - `e2e/react/src/module-federation/federate-module.webpack.test.ts` - `e2e/react/src/module-federation/independent-deployability.webpack.test.ts` - `e2e/react/src/module-federation/misc-rspack-interoperability.test.ts` ## Related Issue(s) Reverts the skip from #35753. Upstream: - webpack/webpack#20988 (compat shim, merged) - webpack/webpack#20989 (webpack 5.107.1 release, merged)
…k 5.107.0 compat (#35753) ## Current Behavior All webpack-based React Module Federation e2e tests started failing on 2026-05-20. Webpack 5.107.0 (published earlier today) reorganized its internal `lib/` directory into subdirectories — e.g. `lib/ModuleNotFoundError.js` moved to `lib/errors/ModuleNotFoundError.js`, `lib/DllPlugin.js` moved to `lib/dll/DllPlugin.js`, etc. `@module-federation/enhanced` (which our generators wire up for webpack-based host/remote apps) deep-imports `require('webpack/lib/ModuleNotFoundError')`, which now throws `MODULE_NOT_FOUND` and aborts every webpack-based MF build/serve in our react e2e suite. Sample failure: ``` NX Cannot find module 'webpack/lib/ModuleNotFoundError' Require stack: - node_modules/@module-federation/enhanced/dist/src/lib/sharing/resolveMatchedConfigs.js - node_modules/@module-federation/enhanced/dist/src/lib/sharing/ConsumeSharedPlugin.js - ... - node_modules/@nx/module-federation/src/with-module-federation/webpack/with-module-federation.js ``` This is upstream's bug, not ours: - webpack/webpack#20985 — closed by webpack maintainer pointing at module-federation - module-federation/core#4747 — open issue for module-federation to stop using private webpack APIs - webpack/webpack#20988 — adds back a `lib/ModuleNotFoundError` compat shim (merged, awaiting a webpack patch release) Even after the shim release lands, other deep imports may still be broken, so we want to fully decouple our CI from this until both ecosystems re-sync. Angular MF goes through the same `@module-federation/enhanced/webpack` code path and would theoretically fail too, but only react tests were observed failing in CI. The angular suites are left enabled so we get a real signal if/when they hit the same issue. ## Expected Behavior CI passes. Webpack-based react MF e2e suites are temporarily skipped with `describe.skip` and a TODO comment linking the upstream tracking issues. Rspack-based MF e2e tests and angular MF e2e tests are untouched and continue to run. Skipped suites: - `e2e/react/src/module-federation/core-webpack-basic-host-remote-generation.test.ts` - `e2e/react/src/module-federation/core-webpack-basic-playwright.test.ts` - `e2e/react/src/module-federation/core-webpack-name-and-root.test.ts` - `e2e/react/src/module-federation/core-webpack-query-params.test.ts` - `e2e/react/src/module-federation/core-webpack-ssr.test.ts` - `e2e/react/src/module-federation/dynamic-federation.webpack.test.ts` - `e2e/react/src/module-federation/federate-module.webpack.test.ts` - `e2e/react/src/module-federation/independent-deployability.webpack.test.ts` - `e2e/react/src/module-federation/misc-rspack-interoperability.test.ts` (both scenarios still build with webpack on one side) ## Related Issue(s) Tracking upstream: - webpack/webpack#20985 - module-federation/core#4747 - webpack/webpack#20988 --------- Co-authored-by: nx-cloud[bot] <71083854+nx-cloud[bot]@users.noreply.github.com> Co-authored-by: FrozenPandaz <FrozenPandaz@users.noreply.github.com> (cherry picked from commit a51e340)
…bpack 5.107.1 fix is live) (#35764) ## Current Behavior PR #35753 skipped 9 webpack-based React Module Federation e2e suites because webpack 5.107.0 (published 2026-05-20) reorganized its `lib/` directory and removed `lib/ModuleNotFoundError.js`, which `@module-federation/enhanced` deep-imports. Every webpack-based MF build/serve in the affected suites was failing with `Cannot find module 'webpack/lib/ModuleNotFoundError'`. ## Expected Behavior webpack 5.107.1 (published 2026-05-21) restored the path as a backward-compat shim — `lib/ModuleNotFoundError.js` now re-exports from `./errors/ModuleNotFoundError`. Verified locally that all 21 `webpack/lib/*` paths used by `@module-federation/enhanced` 2.4.0 / 2.5.0 now resolve in 5.107.1. This PR removes the `describe.skip` + TODO + `// eslint-disable-next-line jest/no-disabled-tests` lines from the 9 affected files, re-enabling: - `e2e/react/src/module-federation/core-webpack-basic-host-remote-generation.test.ts` - `e2e/react/src/module-federation/core-webpack-basic-playwright.test.ts` - `e2e/react/src/module-federation/core-webpack-name-and-root.test.ts` - `e2e/react/src/module-federation/core-webpack-query-params.test.ts` - `e2e/react/src/module-federation/core-webpack-ssr.test.ts` - `e2e/react/src/module-federation/dynamic-federation.webpack.test.ts` - `e2e/react/src/module-federation/federate-module.webpack.test.ts` - `e2e/react/src/module-federation/independent-deployability.webpack.test.ts` - `e2e/react/src/module-federation/misc-rspack-interoperability.test.ts` ## Related Issue(s) Reverts the skip from #35753. Upstream: - webpack/webpack#20988 (compat shim, merged) - webpack/webpack#20989 (webpack 5.107.1 release, merged) (cherry picked from commit b6858ba)
…k 5.107.0 compat (nrwl#35753) ## Current Behavior All webpack-based React Module Federation e2e tests started failing on 2026-05-20. Webpack 5.107.0 (published earlier today) reorganized its internal `lib/` directory into subdirectories — e.g. `lib/ModuleNotFoundError.js` moved to `lib/errors/ModuleNotFoundError.js`, `lib/DllPlugin.js` moved to `lib/dll/DllPlugin.js`, etc. `@module-federation/enhanced` (which our generators wire up for webpack-based host/remote apps) deep-imports `require('webpack/lib/ModuleNotFoundError')`, which now throws `MODULE_NOT_FOUND` and aborts every webpack-based MF build/serve in our react e2e suite. Sample failure: ``` NX Cannot find module 'webpack/lib/ModuleNotFoundError' Require stack: - node_modules/@module-federation/enhanced/dist/src/lib/sharing/resolveMatchedConfigs.js - node_modules/@module-federation/enhanced/dist/src/lib/sharing/ConsumeSharedPlugin.js - ... - node_modules/@nx/module-federation/src/with-module-federation/webpack/with-module-federation.js ``` This is upstream's bug, not ours: - webpack/webpack#20985 — closed by webpack maintainer pointing at module-federation - module-federation/core#4747 — open issue for module-federation to stop using private webpack APIs - webpack/webpack#20988 — adds back a `lib/ModuleNotFoundError` compat shim (merged, awaiting a webpack patch release) Even after the shim release lands, other deep imports may still be broken, so we want to fully decouple our CI from this until both ecosystems re-sync. Angular MF goes through the same `@module-federation/enhanced/webpack` code path and would theoretically fail too, but only react tests were observed failing in CI. The angular suites are left enabled so we get a real signal if/when they hit the same issue. ## Expected Behavior CI passes. Webpack-based react MF e2e suites are temporarily skipped with `describe.skip` and a TODO comment linking the upstream tracking issues. Rspack-based MF e2e tests and angular MF e2e tests are untouched and continue to run. Skipped suites: - `e2e/react/src/module-federation/core-webpack-basic-host-remote-generation.test.ts` - `e2e/react/src/module-federation/core-webpack-basic-playwright.test.ts` - `e2e/react/src/module-federation/core-webpack-name-and-root.test.ts` - `e2e/react/src/module-federation/core-webpack-query-params.test.ts` - `e2e/react/src/module-federation/core-webpack-ssr.test.ts` - `e2e/react/src/module-federation/dynamic-federation.webpack.test.ts` - `e2e/react/src/module-federation/federate-module.webpack.test.ts` - `e2e/react/src/module-federation/independent-deployability.webpack.test.ts` - `e2e/react/src/module-federation/misc-rspack-interoperability.test.ts` (both scenarios still build with webpack on one side) ## Related Issue(s) Tracking upstream: - webpack/webpack#20985 - module-federation/core#4747 - webpack/webpack#20988 --------- Co-authored-by: nx-cloud[bot] <71083854+nx-cloud[bot]@users.noreply.github.com> Co-authored-by: FrozenPandaz <FrozenPandaz@users.noreply.github.com>
…bpack 5.107.1 fix is live) (nrwl#35764) ## Current Behavior PR nrwl#35753 skipped 9 webpack-based React Module Federation e2e suites because webpack 5.107.0 (published 2026-05-20) reorganized its `lib/` directory and removed `lib/ModuleNotFoundError.js`, which `@module-federation/enhanced` deep-imports. Every webpack-based MF build/serve in the affected suites was failing with `Cannot find module 'webpack/lib/ModuleNotFoundError'`. ## Expected Behavior webpack 5.107.1 (published 2026-05-21) restored the path as a backward-compat shim — `lib/ModuleNotFoundError.js` now re-exports from `./errors/ModuleNotFoundError`. Verified locally that all 21 `webpack/lib/*` paths used by `@module-federation/enhanced` 2.4.0 / 2.5.0 now resolve in 5.107.1. This PR removes the `describe.skip` + TODO + `// eslint-disable-next-line jest/no-disabled-tests` lines from the 9 affected files, re-enabling: - `e2e/react/src/module-federation/core-webpack-basic-host-remote-generation.test.ts` - `e2e/react/src/module-federation/core-webpack-basic-playwright.test.ts` - `e2e/react/src/module-federation/core-webpack-name-and-root.test.ts` - `e2e/react/src/module-federation/core-webpack-query-params.test.ts` - `e2e/react/src/module-federation/core-webpack-ssr.test.ts` - `e2e/react/src/module-federation/dynamic-federation.webpack.test.ts` - `e2e/react/src/module-federation/federate-module.webpack.test.ts` - `e2e/react/src/module-federation/independent-deployability.webpack.test.ts` - `e2e/react/src/module-federation/misc-rspack-interoperability.test.ts` ## Related Issue(s) Reverts the skip from nrwl#35753. Upstream: - webpack/webpack#20988 (compat shim, merged) - webpack/webpack#20989 (webpack 5.107.1 release, merged)
Some old plugins use
require("webpack/lib/ModuleNotFoundError")directly.Add a re-export at the legacy path, mirroring how
lib/WebpackError.jsre-exports
./errors/WebpackError. Marked with a TODO to remove in webpack@6.Refs #20985