File tree Expand file tree Collapse file tree 7 files changed +49
-10
lines changed Expand file tree Collapse file tree 7 files changed +49
-10
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @module-federation/runtime ' : patch
3
+ ---
4
+
5
+ fix(runtime): add define constant to help downgrade non-esm project
Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @module-federation/modern-js ' : patch
3
+ ---
4
+
5
+ fix(modern-js-plugin): only export esm mfRuntimePlugin
Original file line number Diff line number Diff line change 35
35
"import" : " ./dist/esm/cli/ssrPlugin.js" ,
36
36
"require" : " ./dist/cjs/cli/ssrPlugin.js" ,
37
37
"types" : " ./dist/types/cli/ssrPlugin.d.ts"
38
+ },
39
+ "./shared-strategy" : {
40
+ "import" : " ./dist/esm/cli/mfRuntimePlugins/shared-strategy.js" ,
41
+ "require" : " ./dist/esm/cli/mfRuntimePlugins/shared-strategy.js" ,
42
+ "types" : " ./dist/types/cli/mfRuntimePlugins/shared-strategy.d.ts"
43
+ },
44
+ "./resolve-entry-ipv4" : {
45
+ "import" : " ./dist/esm/cli/mfRuntimePlugins/resolve-entry-ipv4.js" ,
46
+ "require" : " ./dist/esm/cli/mfRuntimePlugins/resolve-entry-ipv4.js" ,
47
+ "types" : " ./dist/types/cli/mfRuntimePlugins/resolve-entry-ipv4.d.ts"
48
+ },
49
+ "./inject-node-fetch" : {
50
+ "import" : " ./dist/esm/cli/mfRuntimePlugins/inject-node-fetch.js" ,
51
+ "require" : " ./dist/esm/cli/mfRuntimePlugins/inject-node-fetch.js" ,
52
+ "types" : " ./dist/types/cli/mfRuntimePlugins/inject-node-fetch.d.ts"
38
53
}
39
54
},
40
55
"typesVersions" : {
50
65
],
51
66
"ssr-plugin" : [
52
67
" ./dist/types/cli/ssrPlugin.d.ts"
68
+ ],
69
+ "shared-strategy" : [
70
+ " ./dist/types/cli/mfRuntimePlugins/shared-strategy.d.ts"
71
+ ],
72
+ "resolve-entry-ipv4" : [
73
+ " ./dist/types/cli/mfRuntimePlugins/resolve-entry-ipv4.d.ts"
74
+ ],
75
+ "inject-node-fetch" : [
76
+ " ./dist/types/cli/mfRuntimePlugins/inject-node-fetch.d.ts"
53
77
]
54
78
}
55
79
},
Original file line number Diff line number Diff line change @@ -39,9 +39,9 @@ describe('patchMFConfig', async () => {
39
39
} ,
40
40
remoteType : 'script' ,
41
41
runtimePlugins : [
42
- path . resolve ( __dirname , './mfRuntimePlugins /shared-strategy.js ') ,
42
+ require . resolve ( '@module-federation/modern-js /shared-strategy') ,
43
43
require . resolve ( '@module-federation/node/runtimePlugin' ) ,
44
- path . resolve ( __dirname , './mfRuntimePlugins /inject-node-fetch.js ') ,
44
+ require . resolve ( '@module-federation/modern-js /inject-node-fetch') ,
45
45
] ,
46
46
shared : {
47
47
react : {
@@ -69,7 +69,7 @@ describe('patchMFConfig', async () => {
69
69
} ,
70
70
remoteType : 'script' ,
71
71
runtimePlugins : [
72
- path . resolve ( __dirname , './mfRuntimePlugins /shared-strategy.js ') ,
72
+ require . resolve ( '@module-federation/modern-js /shared-strategy') ,
73
73
] ,
74
74
shared : {
75
75
react : {
Original file line number Diff line number Diff line change @@ -146,13 +146,13 @@ export const patchMFConfig = (
146
146
patchDTSConfig ( mfConfig , isServer ) ;
147
147
148
148
injectRuntimePlugins (
149
- path . resolve ( __dirname , './mfRuntimePlugins /shared-strategy.js ') ,
149
+ require . resolve ( '@module-federation/modern-js /shared-strategy') ,
150
150
runtimePlugins ,
151
151
) ;
152
152
153
153
if ( isDev ) {
154
154
injectRuntimePlugins (
155
- path . resolve ( __dirname , './mfRuntimePlugins /resolve-entry-ipv4.js ') ,
155
+ require . resolve ( '@module-federation/modern-js /resolve-entry-ipv4') ,
156
156
runtimePlugins ,
157
157
) ;
158
158
}
@@ -172,7 +172,7 @@ export const patchMFConfig = (
172
172
}
173
173
174
174
injectRuntimePlugins (
175
- path . resolve ( __dirname , './mfRuntimePlugins /inject-node-fetch.js ') ,
175
+ require . resolve ( '@module-federation/modern-js /inject-node-fetch') ,
176
176
runtimePlugins ,
177
177
) ;
178
178
Original file line number Diff line number Diff line change @@ -2,3 +2,4 @@ declare const __VERSION__: string;
2
2
declare const FEDERATION_DEBUG : string ;
3
3
declare const FEDERATION_BUILD_IDENTIFIER : string | undefined ;
4
4
declare const __RELEASE_NUMBER__ : number ;
5
+ declare const FEDERATION_ALLOW_NEW_FUNCTION : string | undefined ;
Original file line number Diff line number Diff line change @@ -25,9 +25,14 @@ async function loadEsmEntry({
25
25
return new Promise < RemoteEntryExports > ( ( resolve , reject ) => {
26
26
try {
27
27
if ( ! remoteEntryExports ) {
28
- import ( /* webpackIgnore: true */ /* @vite -ignore */ entry )
29
- . then ( resolve )
30
- . catch ( reject ) ;
28
+ if ( typeof FEDERATION_ALLOW_NEW_FUNCTION !== 'undefined' ) {
29
+ new Function (
30
+ 'callbacks' ,
31
+ `import("${ entry } ").then(callbacks[0]).catch(callbacks[1])` ,
32
+ ) ( [ resolve , reject ] ) ;
33
+ } else {
34
+ import ( /* webpackIgnore: true */ /* @vite -ignore */ entry ) . then ( resolve ) . catch ( reject ) ;
35
+ }
31
36
} else {
32
37
resolve ( remoteEntryExports ) ;
33
38
}
@@ -223,7 +228,6 @@ export async function getRemoteEntry({
223
228
224
229
if ( ! globalLoading [ uniqueKey ] ) {
225
230
const loadEntryHook = origin . remoteHandler . hooks . lifecycle . loadEntry ;
226
- const createScriptHook = origin . loaderHook . lifecycle . createScript ;
227
231
const loaderHook = origin . loaderHook ;
228
232
229
233
globalLoading [ uniqueKey ] = loadEntryHook
You can’t perform that action at this time.
0 commit comments