-
-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nodeRuntimePlugin is not usable outside webpack bundles #2968
Comments
I found this: https://github.com/module-federation/module-federation-examples/blob/master/dynamic-remotes-node/pure-server.js How do I use this ? |
This relies on the chunks having been built by webpack in the first place. We patch the chunk loader so it still needs to be a runtime encoded to loading webpack chunk formats |
how node federation plugin works is: const chunkMap = { webpack_require.f.readFile = (chunkID)=>{ We depend on webpacks runtime to augment the filesystem |
I am curious whether we can use this or not: https://nodejs.org/api/module.html#hooks I will write a quick POC and get back. |
@ScriptedAlchemy I updated my minimal example to use webpack but it still fails https://github.com/MadaraUchiha-314/nailsmith Error: shell-remote-entry.js:6130
/******/ execOptions.factory.call(module.exports, module, module.exports, execOptions.require);
^
TypeError: Cannot read properties of undefined (reading 'call')
at __webpack_require__ (shell-remote-entry.js:6130:32)
at fn (shell-remote-entry.js:6314:21)
at shell-remote-entry.js:5782:186
at /Users/rohithr31/code/github.com/MadaraUchiha-314/nailsmith/packages/bff/dist/index.js:379:29
at Module.get (/Users/rohithr31/code/github.com/MadaraUchiha-314/nailsmith/packages/bff/dist/index.js:358:37)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async RemoteHandler.loadRemote (/Users/rohithr31/code/github.com/MadaraUchiha-314/nailsmith/packages/bff/dist/index.js:1603:37)
at async run (/Users/rohithr31/code/github.com/MadaraUchiha-314/nailsmith/packages/bff/dist/index.js:28929:20) |
I was able to move past the above bug. I'll talk about the bug and the fix later. It's an interesting one. But where we are stuck at is when we are calling The problem is that that code taps into webpack + federation internals: __webpack_require__.federation.instance.moduleCache.clear(); https://github.com/module-federation/core/blob/main/packages/node/src/utils/hot-reload.ts#L56 @ScriptedAlchemy Is there a way to implement this module cache clear without tapping into webpack internals and rather use the |
Send pr. Sure we can adjust to use global. |
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#configurationI am getting the following error:
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
Validations
The text was updated successfully, but these errors were encountered: