Comments (14)
I should be releaseing support for splitChunks api in next which may improve this issue for you
from module-federation-examples.
@ScriptedAlchemy Thanks, I will try the version on my project, and whether it works well or not I will report back to you.
from module-federation-examples.
Okay the federation package duplicaiton, this is because of how next works. We inject federation runtime into the entrypoint, i then manually use another plugin for next to hoist it into the runtime chunk, but because next uses entry routing and single runtime chunk - each entrypoint contains the runtime package. I can try and scope this down specifically for next.js by attempting to only inject federation runtime into _app.js - next is very sub-optimal unfortunately.
Regarding eager use, eager:true hoists the modules to the top of the runtime, except in next where it only hoists them to the entrypoints, not to the runtime chunks - making eager true not actually eager since its sitting in the entrypoint not the webpack runtime chunk. This is a problem in the eager + multi entry + single runtime chunk, this is a problem in webpacks core.
Instead of relying on eager to try and ensure dependnecy control id use a runtime plugin. With runtime plugins you can take control of the resolver logic of shared and you can force your remotes to always "pick" a certan shared module from another host/remote.
Look at the nextjs internal runtime plugin for example, the runtime plugin uses resolveShare which tells all remotes to prefer the hosts react and react dom, as well and the hosts next/router share over any others provided by the system. Effectively works like what youre trying to do with eager true, which is ensure that the loaded one is used.
Resolve share would let you control this deterministically.
from module-federation-examples.
Hi @ScriptedAlchemy, I also get the same problem.
Have you had any updated on this issue?
I think that is not a small issue so if this issue is fixed, that is a most significant point at this moment.
I can not wait more time.
Does this release solve the problem?
0.0.0-next-20240424224724
from module-federation-examples.
Due to bug in webpack and federation when single runtime chunk is used.
Shared modules are only hoisted up to the entrypoint level, not the runtime level - causing duplication acorss entrypoints.
from module-federation-examples.
Thanks @ScriptedAlchemy
from module-federation-examples.
@duyphuong2101 you can try this release, i cut it with the new split chunks mods - you can see if it works better or not.
0.0.0-next-20240424224724
from module-federation-examples.
Hi @ScriptedAlchemy
I took version 0.0.0-next-20240424224724 and tested it on my project, but still getting the same errors. You can take my test project to check
https://github.com/duannx/mf-duplicate-bundle-size-issue/blob/master/README.md
from module-federation-examples.
Are you sharing lodash as eager? Don't use eager sharing
from module-federation-examples.
Hi @ScriptedAlchemy, I'm taking over for my colleague.
Yes, we are using eager. We tested with eager : false
and lodash
is correctly tree-shaken. But the module federation bundle is still there and is duplicated into three chunks: main
, webpack
, and remoteEntry
. All of them are used on the page so we are loading redundant JS
I have a small concern about the eager
option. So we should not use it anymore, should we? Is there any difference between eager : true
and eager : false
on the latest version of @module-federation/nextjs-mf
? The reason that we want to use eager : true
is that some modules really need to be loaded before other modules. Because they are dependencies of others in a complexity graph. I'm not sure if switching to eager : false
would introduce another issue that we don't foresee
Thanks in advance!
from module-federation-examples.
Thank you for that. I'll give it a try
from module-federation-examples.
Hi @ScriptedAlchemy, is there any update on this issue? Thank you!
from module-federation-examples.
Hi @ScriptedAlchemy, I also get the same problem.
Have you had any updated on this issue?
I think that is not a small issue so if this issue is fixed, that is a most significant point at this moment.
I can not wait more time.
from module-federation-examples.
Hi @ScriptedAlchemy , I have checked on the new version that you provided but the issue is happened.
When I checked the the bundle on analyzer tool, I also saw the duplication of the module-federation.
Can you double check that?
from module-federation-examples.
Related Issues (20)
- Hot Module Reloading is solved! HOT 1
- Can I Remove remote.js?[hash] for cache remote.js HOT 2
- NPM package unavailable - nextjs-shared-v14 HOT 1
- [Bug][Nextjs13] Uncaught TypeError: Cannot read properties of undefined (reading 'consumes') HOT 2
- Examples issue HOT 3
- vue-cli master分支跑不起来 HOT 1
- [Question] URL parameters? HOT 6
- externals @module-federation/webpack-bundler-runtime no work HOT 1
- Dynamic-remotes shared config not work HOT 2
- Does V2 currently support Vite? HOT 1
- Microfe
- nextjs mf does not generate remoteEntry.js HOT 6
- Add ability to reduce requests waterfall for host-ui HOT 3
- [Help] Router Module forRoot Issue with Module Federation HOT 1
- css-Isolation not working in rspack example HOT 2
- Does it work with the Next 14 App router? HOT 2
- vite-react-microfrontends example is broken
- Lost css style of remote app when call from host at production mode
- Cannot export _app.js with Next module federation
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 module-federation-examples.