Skip to content

Commit 3a632be

Browse files
committed
fix(mfe): force remote container export on window
1 parent b06c9d8 commit 3a632be

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

webpack/webpack.common.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ const isMfeHost = mfeRole === 'host'
2828
const isMfeRemote = mfeRole === 'remote'
2929
const isMfeEnabled = isMfeHost || isMfeRemote
3030

31+
const mfeName = isMfeEnabled ? toMfeName(paths.projectName) : undefined
32+
3133
const toMfeName = (name) => {
3234
const raw = (name || '').toString().trim() || 'app'
3335
const safe = raw.replace(/[^a-zA-Z0-9_]/g, '_')
@@ -130,6 +132,9 @@ const config = {
130132
asyncFunction: true,
131133
},
132134
uniqueName: isMfeEnabled ? toMfeName(paths.projectName) : undefined,
135+
// For MF remotes in production we must expose the container globally so the host can find it.
136+
// Using a string-keyed window export avoids minifier renaming issues.
137+
library: isMfeRemote && mfeName ? { type: 'window', name: mfeName } : undefined,
133138
filename: isDev ? 'static/js/[name].js' : 'static/js/[name].[contenthash].js',
134139
chunkFilename: isDev ? 'static/js/[name].js' : 'static/js/[name].[contenthash].js',
135140
// library: '',

0 commit comments

Comments
 (0)