Comments (6)
Lol okay sorry.
Here we go
As long as you have async bootstrap import, or a parent import, you can use static import without a problem.
It's not "bad" but you will be loading more code upfront in order for that chunk to start.
I always say use dynamic import when possible because it's better for code splitting. We don't have to load as much code in the parent chunk.
Using static imports is sometimes necessary. React hooks for example. Those we can static import because it's hard not to.
But where async can be used, we want to use it. So that we are not creating giant amount s of remote code be downloaded because everything is going back to the top bootstrap import.
The bootstrap import itself is only in all my example because everything needs react to start. So there's not much else to go in the entry point other than importing react.
If you're entry-point contained no static import of a shared module, then you can code as normal. Just make sure to dynamic import the bootstrap file when you want the shared modules to start.
Is that a better explanation?
Many static imported federated modules would be bad practice- not problematic for webpack. Just not what we advise for heavy use (perf)
from module-federation-examples.
You need to have a dynamic import somewhere in the parent to leverage static imports. This works by hoisting additional chunks to the nearest parent async import. This is how we can provide them in a sync manner, by moving them somewhere that we already have a promise pausing execution. If you use a dynamic import for bootstrap.js, usually solves the issue.
from module-federation-examples.
Thank you for the answering. 🙂
Can I say, if handled with care, it is possible to use module federation with just static import like before?
I am not super clear that you said 'If you use a dynamic import for bootstrap.js, usually solves the issue'. The example is using dynamic import for the bootstrap.js but the React.lazy
and Suspense
is still needed in the case?
from module-federation-examples.
from module-federation-examples.
Static imports, used or not would be loaded since they are eager imports.
from module-federation-examples.
Oh, I see
from module-federation-examples.
Related Issues (20)
- Module not found: Can't resolve 'encoding' in '../node_modules/node-fetch/lib' HOT 3
- Please use Angular17.2 as the shell, use the Native Federation package, Angular12 as the remote, use the Module Federation package. Is there any such example? HOT 1
- Is there any example of using server rendering with rspack? HOT 1
- vite-react-microfrontends demo missing file HOT 5
- nextjs(host)+ react webpack(remote):No ModuleFederationPlugin(s) found. HOT 15
- Any Next.js 14 example? HOT 2
- nextjs-v13 routing does not work HOT 1
- nextjs-v13 getServerSideProps not working HOT 10
- Using external-remotes-plugin with @module-federation/nextjs-mf HOT 1
- Uncaught SyntaxError: Unexpected token function when use module federation v1.5 HOT 3
- Code Nextjs-v14 throws error when try to run HOT 5
- [Feature request/discussion] Allow having multiple instances of shared dependencies HOT 3
- Hot Module Reloading is solved! HOT 1
- [Question] Shared modules are duplicate in multi-bundle files of MF v8.2.2 above HOT 10
- 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
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.