Compute `ModuleFederationPlugin`s remotes' URLs in the runtime
See original GitHub issueWith the remotes
property we define where to pull remotes from:
remotes: {
widget: `widget@http://localhost:3001/remoteEntry.js`,
},
It is possible to alternate the URL during the build
remotes: {
widget: `widget@${isDev ? 'http://localhost:3001' : '/apps/widgets'}/remoteEntry.js`,
},
Though it seems like there is no way to define the remote’s URL dynamically in runtime.
I would imagine it like this:
remotes: {
widget: () => {
const prefix = location.host.startsWith('eu.') ? 'europe' : 'us';
return `widget@${prefix}/apps/widgets/remoteEntry.js`
},
},
It would be really useful to have such an option.
_Originally posted by @jazzfog in https://github.com/webpack/webpack/discussions/12213_
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Module Federation: remote url with slug possible in webpack ...
Is it possible to dynamically change the remote url in the webpack.config file to include slugs which can change during runtime? Webpack config ......
Read more >Module Federation - webpack
ModuleFederationPlugin combines ContainerPlugin and ContainerReferencePlugin . ... Generally, remotes are configured using URL's like in this example:
Read more >Tutorial - A Guide to Module Federation for Enterprise
new ModuleFederationPlugin({ remotes: { FormApp: ... If a remote app URL changes, teams must remember to change both the remote app and host ......
Read more >Webpack 5 Module Federation — Stitching two simple ...
Sharing code between themselves at runtime. ... execution for a moment to let the Webpack runtime interface with any remotes and comprehends ...
Read more >4 Ways to Use Dynamic Remotes in Module Federation
It allows us to resolve the URLs at runtime using templating: plugins: [. new ModuleFederationPlugin({. name: "Host",. remotes: {.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Still think it’d be a useful feature.
remotes basically are external modules, you can use
promise
external see webpack test case for that https://github.com/webpack/webpack/blob/main/test/configCases/container/circular/webpack.config.jsso for dynamic externals please use
promise