Comments (8)
federation is assign based, it object assigns new over old, since the keys (version) is the same - it doesn't matter to init order.
You can put it into loaded-first which may prevent this.
import type { FederationRuntimePlugin } from '@module-federation/enhanced/runtime';
const sharedStrategy: () => FederationRuntimePlugin = () => ({
name: 'shared-strategy-plugin',
beforeInit(args) {
const { userOptions } = args;
const shared = userOptions.shared;
if (shared) {
Object.keys(shared).forEach((sharedKey) => {
const sharedConfigs = shared[sharedKey];
const arraySharedConfigs = Array.isArray(sharedConfigs)
? sharedConfigs
: [sharedConfigs];
arraySharedConfigs.forEach((s) => {
s.strategy = 'loaded-first';
});
});
}
return args;
},
});
export default sharedStrategy;
from universe.
The solution works! but .....
It works when I use @module-federation/enhanced/webpack
. But when I use webpack/lib/container/ModuleFederationPlugin.js
, it doesn't work because there's no concept of runtime plugins in that.
I have updated my above mentioned stackblitz example to reflect it.
But interestingly, beforeInit
is not even called for the MF 1.0 remote. Even if it is called, because there's no federation runtime, the only way a MF 1.0 remote will not wipe out the share scope is if we forcefully add loaded: true
to the packages provided by the host.
Hence my proposal is to modify the SharedBaseArgs to add one additional param to mark any module as loaded
. If loaded: true
is an internal state, we can rename it to something else like preferred or whatever, but internally it will mark that module as loaded: true
after which MF 1.0 container will start using it.
from universe.
Related Issues (20)
- Adding element to page with id that matches remote's name causes `TypeError: remoteEntryExports.init is not a function` HOT 2
- External modules not shared HOT 4
- [MF Plugin] "promise new Promise" syntax doesn't work with @ char in it HOT 4
- Entry runtime miss function "O" HOT 6
- esbuild plugin error: Top-level await is not available in the configured target environment HOT 1
- @module-federation/nextjs-mf version 8.4.0 breaks API routes
- Having production error - TypeError: (void 0) is not a function at .next/server/webpack-api-runtime.js:1:199 HOT 1
- Nextjs plugin doesn't work unless the "unsafe-eval" CSP header is set
- Vue Bridge package lacks `dist` HOT 4
- misleading error message when remoteEntry.files is empty
- Module Federation Plugin for Vite HOT 8
- Quick Start Error - Failed to load file HOT 4
- Project with tsconfig.json with compilerOptions.paths and path aliases usage fails to compile federated types HOT 3
- Missing `dist` in the release of `@module-federation/bridge-vue3` HOT 2
- Critical dependency warning in @module-federation/utilities due to dynamic import HOT 6
- add option to exclude shared dependencies from build HOT 6
- Nx angular dynamic mfe got NG0203 error HOT 6
- @module-federation/enhanced v0.3.1 includes reference to missing module in .d.ts file HOT 2
- TS errors after switching from webpack's Module Federation to Module Fedaration V2 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from universe.