You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fetching remote-entry files dynamically and support of experiments.outputModule #18119
I've encountered an issue with dynamically loading remote-entry files (fetching remote-entry files as needed) using Module Federation. I have a custom module loader that uses __webpack_require__.l() to fetch remote-entry files dynamically, as described in the Module Federation Plugin documentation.
To ensure __webpack_require__.l() is defined, I'm employing a workaround that involves dynamically importing a fake module (await import('./FakeModule.js')). While this successfully generates the __webpack_require__.l() definition, it has an unintended side effect: the webpack/runtime/publicPath (__webpack_require__.p) is set based on the baseURL of my module loader, rather than being recalculated for each use.
This has led to incorrect URLs for chunk loading, as __webpack_require__.f.j() calculates the chunk URL using the following pattern:
I've found that setting output.library.type: 'module' and enabling experiments.outputModule allows __webpack_require__.p to be set correctly using import.meta.url. However, this is not an ideal solution as it relies on experimental features.
I have two questions for the community:
I would like to avoid building my own script tag creation and eventing code, and utilize as much in model webpack code as possible.
Are there any plans to support experiments.outputModule in future Webpack versions, or to stabilize this in the feature?
Any insights or suggestions on this matter would be greatly appreciated.
For us problems with module federation (stack trace within a federation entry file, i[e] is not a function on the console => i[e] is a chunk usually but appears to be undefined) by switching from 5.90.1 (working) to 5.90.2 (broken). I tested 5.90.3 as well (still broken in seemingly the same way to this regard).
It's a huge project with loads of modules, only one of these looks like creating some kind of trouble for some reason. I lack experience in debugging within the packager. Is there anything useful I can/should provide to help. I have the feeling it might be related to what is being described here, but could also be an unrelated error.
Im not sure if webpack will accept the enhancements made in here, it is also easier to maintain parity with webpack and rspack when both depend on a central runtime vs it coupled deeply to bundler.
What i did is extract the runtime code from webpack and author a library, then i added the hooks on require as needed, like f.consumes etc to bind it back to the bundler runtime.
indeed, im not sure what your opinion is on depending on module-federation/runtime - but we would always introcude this back into the webpack plugin, otherwise one can use the enhanced plugin
Activity
harirsskrishna commentedon Feb 26, 2024
@ScriptedAlchemy do you have any inputs?
jdehaan commentedon Feb 27, 2024
For us problems with module federation (stack trace within a federation entry file, i[e] is not a function on the console => i[e] is a chunk usually but appears to be
undefined) by switching from 5.90.1 (working) to 5.90.2 (broken). I tested 5.90.3 as well (still broken in seemingly the same way to this regard).It's a huge project with loads of modules, only one of these looks like creating some kind of trouble for some reason. I lack experience in debugging within the packager. Is there anything useful I can/should provide to help. I have the feeling it might be related to what is being described here, but could also be an unrelated error.
alexander-akait commentedon Feb 27, 2024
@harirsskrishna Please format your issue using the issue template, otherwise I will move it in
Dicussions, thank youharirsskrishna commentedon Feb 28, 2024
@alexander-akait , I believe this better fits in the
Discussionssection. Please feel free to move it toDiscussions.fix: should use new runtime to reconsider skipped connections
ScriptedAlchemy commentedon Mar 5, 2024
Look at module-federation/enhanced. I forked it out of webpack and added a hook lifecycle for runtime plugins.
Or module-federation/runtime which has all the mechanics.
alexander-akait commentedon Mar 6, 2024
@ScriptedAlchemy Do we need something improve on webpack side?
ScriptedAlchemy commentedon Mar 7, 2024
Im not sure if webpack will accept the enhancements made in here, it is also easier to maintain parity with webpack and rspack when both depend on a central runtime vs it coupled deeply to bundler.
What i did is extract the runtime code from webpack and author a library, then i added the hooks on require as needed, like f.consumes etc to bind it back to the bundler runtime.
If users want to adjust internals etc. You can write a runtime plugin that gives you access to the lifecycles.
for example:
https://github.com/module-federation/module-federation-examples/blob/master/runtime-plugins/remote-control/app1/pick-remote.ts
Might be useful.
alexander-akait commentedon Mar 7, 2024
@ScriptedAlchemy sounds intresting, it can be useful, we have hooks, so I think we can solve it by them
ScriptedAlchemy commentedon Mar 7, 2024
indeed, im not sure what your opinion is on depending on module-federation/runtime - but we would always introcude this back into the webpack plugin, otherwise one can use the enhanced plugin
webpack-bot commentedon Jun 7, 2024
This issue had no activity for at least three months.
It's subject to automatic issue closing if there is no activity in the next 15 days.
webpack-bot commentedon Jun 22, 2024
Issue was closed because of inactivity.
If you think this is still a valid issue, please file a new issue with additional information.