Paylaşılan Bağımlılıklar ve Sürüm Yönetimi
Module Federation'ın kitaplıkları mikro ön uçlar arasında nasıl paylaştığını, tekil örneklerin ve sürüm uzlaşmasının nasıl çalıştığını ve yinelenen paketleri ve çalışma zamanı bozulmalarını önleyen en iyi uygulamaları öğrenin.
Paylaşılan Bağımlılıklar ve Sürüm Yönetimi, CoddyKit'te ücretsiz bir Micro Frontends Architecture with Module Federation dersidir. Bu, 4 dersinin 4. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Micro Frontends Architecture with Module Federation öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Micro Frontends Architecture with Module Federation kursu toplamda 4 dersten oluşur.
Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.
Why Sharing Matters
In a Module Federation setup every remote can bundle its own copy of react, react-dom, or a design system. Without coordination, a single page may load three copies of React.
Shared dependencies let independently deployed apps agree on a single instance of a library at runtime, cutting payload and avoiding state bugs.
The shared Key
Both host and remotes declare a shared block in their ModuleFederationPlugin config. Webpack then negotiates which version actually loads.
new ModuleFederationPlugin({
name: 'host',
shared: {
react: { singleton: true },
'react-dom': { singleton: true }
}
})Singletons Explained
singleton: true forces one and only one copy across the whole app. This is essential for libraries that hold internal state, like React (hooks) or a router.
Without it, two React instances cause the dreaded Invalid hook call error.
Version Negotiation
Each shared module declares a requiredVersion. At load time Module Federation picks the highest compatible version among all that are offered.
shared: {
react: {
singleton: true,
requiredVersion: '^18.2.0'
}
}Strict Version Mismatch
When a remote needs a version incompatible with the loaded singleton, Module Federation logs a warning and uses the existing one. With strictVersion: true it instead throws, surfacing the mismatch early.
shared: {
react: { singleton: true, strictVersion: true, requiredVersion: '18.2.0' }
}Eager vs Lazy Sharing
By default shared modules load asynchronously, which requires a bootstrap entry. Setting eager: true bundles the dependency into the initial chunk so no async boundary is needed.
Use eager only for the host shell; eager everywhere defeats the purpose of sharing.
shared: {
react: { singleton: true, eager: true }
}The bootstrap Pattern
Because shared modules resolve asynchronously, the standard pattern splits the entry into index.js (just an import) and bootstrap.js (the real app). This defers execution until the share scope is ready.
// index.js
import('./bootstrap');
// bootstrap.js
import App from './App';
// ... mount AppSharing a Design System
A shared component library should usually be a singleton too, so theming context and CSS-in-JS instances are not duplicated.
shared: {
'@acme/ui': { singleton: true, requiredVersion: '^3.0.0' }
}Auto-Sharing from package.json
Instead of listing versions by hand, you can pass an array and let the plugin read versions from package.json. Tools like the Module Federation Enhanced plugin can even auto-share all dependencies.
shared: ['react', 'react-dom', 'react-router-dom']Diagnosing Duplicate Copies
To confirm sharing works, inspect the Network tab: you should see one vendor chunk for the shared lib. Bundle analyzers and the runtime share scope (__webpack_share_scopes__.default) help debug.
Best Practices Summary
- Singleton for stateful libs (React, router, stores).
- Set
requiredVersionto align teams. - Keep
eageronly on the host shell. - Audit bundles regularly for accidental duplicates.
Quick Check
Which option ensures only one instance of React loads across all micro frontends?
Recap
You learned how Module Federation shares dependencies: singletons for stateful libs, version negotiation via requiredVersion/strictVersion, eager vs lazy loading, and the bootstrap pattern. Proper sharing slashes bundle size and prevents subtle runtime bugs.
Sıkça Sorulan Sorular
“Paylaşılan Bağımlılıklar ve Sürüm Yönetimi” dersi ücretsiz mi?
Evet — “Paylaşılan Bağımlılıklar ve Sürüm Yönetimi” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Micro Frontends Architecture with Module Federation kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Micro Frontends Architecture with Module Federation kursu toplamda 4 dersten oluşur.
“Paylaşılan Bağımlılıklar ve Sürüm Yönetimi” dersinde ne öğreneceğim?
Module Federation'ın kitaplıkları mikro ön uçlar arasında nasıl paylaştığını, tekil örneklerin ve sürüm uzlaşmasının nasıl çalıştığını ve yinelenen paketleri ve çalışma zamanı bozulmalarını önleyen e… Micro Frontends Architecture with Module Federation ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.
Micro Frontends Architecture with Module Federation öğrenmeye başlamak için deneyim gerekli mi?
Önceden deneyim gerekmez. CoddyKit'te Micro Frontends Architecture with Module Federation, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 4. dersidir.
“Paylaşılan Bağımlılıklar ve Sürüm Yönetimi” dersi ne kadar sürer?
Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.
Bu Micro Frontends Architecture with Module Federation dersinde kod yazıp çalıştırabilir miyim?
Evet. Her Micro Frontends Architecture with Module Federation dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.
Bu kursun tüm dersleri
- Tek Depolar ve Çoklu Depolar
- Kurumsal Zorluklar ve Çözümler
- Mikro Ön Yüzlerin ve Federasyonun Geleceği
- Paylaşılan Bağımlılıklar ve Sürüm Yönetimi