core
core copied to clipboard
nodeRuntimePlugin is not usable outside webpack bundles
Describe the bug
I am using Module Federation Runtime + nodeRuntimePlugin
from @module-federation/node/runtimePlugin
as provided in the example here: https://module-federation.io/plugin/plugins/index.html#configuration
I am getting the following error:
ReferenceError: [ Federation Runtime ]: __webpack_require__ is not defined
at <anonymous> (/Users/rohithr31/code/github.com/MadaraUchiha-314/nailsmith/node_modules/@module-federation/node/src/runtimePlugin.ts:234:9)
at beforeInit (/Users/rohithr31/code/github.com/MadaraUchiha-314/nailsmith/node_modules/@module-federation/node/src/runtimePlugin.ts:337:9)
at SyncWaterfallHook.emit (/Users/rohithr31/code/github.com/MadaraUchiha-314/nailsmith/node_modules/@module-federation/runtime/dist/index.cjs.js:448:34)
at FederationHost.formatOptions (/Users/rohithr31/code/github.com/MadaraUchiha-314/nailsmith/node_modules/@module-federation/runtime/dist/index.cjs.js:1925:108)
at new FederationHost (/Users/rohithr31/code/github.com/MadaraUchiha-314/nailsmith/node_modules/@module-federation/runtime/dist/index.cjs.js:2016:29)
at init (/Users/rohithr31/code/github.com/MadaraUchiha-314/nailsmith/node_modules/@module-federation/runtime/dist/index.cjs.js:2027:30)
at run (/Users/rohithr31/code/github.com/MadaraUchiha-314/nailsmith/packages/bff/src/index.ts:9:3)
at nodeRuntimePlugin (/Users/rohithr31/code/github.com/MadaraUchiha-314/nailsmith/packages/bff/src/index.ts:32:1)
at Object.<anonymous> (/Users/rohithr31/code/github.com/MadaraUchiha-314/nailsmith/packages/bff/src/index.ts:32:5)
at Module._compile (node:internal/modules/cjs/loader:1233:14)
node:internal/process/promises:289
triggerUncaughtException(err, true /* fromPromise */);
This is because nodeRuntimePlugin
references __webpack_require__
and my bundle is not generated using webpack.
This needs to be fixed as it make the nodeRuntimePlugin
unusable outside of webpack.
Reproduction
https://github.com/MadaraUchiha-314/nailsmith
Used Package Manager
npm
System Info
NA
Validations
- [X] Read the docs.
- [X] Read the common issues list.
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [X] Make sure this is a Module federation issue and not a framework-specific issue.
- [X] The provided reproduction is a minimal reproducible example of the bug.