-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
Fetching remote-entry files dynamically and support of experiments.outputModule #18119
Comments
@ScriptedAlchemy do you have any inputs? |
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 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. |
@harirsskrishna Please format your issue using the issue template, otherwise I will move it in |
@alexander-akait , I believe this better fits in the |
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. |
@ScriptedAlchemy Do we need something improve on webpack side? |
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. Might be useful. |
@ScriptedAlchemy sounds intresting, it can be useful, we have hooks, so I think we can solve it by them |
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 |
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. |
Hello Webpack contributors,
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: thewebpack/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 enablingexperiments.outputModule
allows__webpack_require__.p
to be set correctly usingimport.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.
Thank you for your time and assistance.
Best regards,
Hari
The text was updated successfully, but these errors were encountered: