File tree Expand file tree Collapse file tree 2 files changed +19
-10
lines changed
packages/runtime/src/utils Expand file tree Collapse file tree 2 files changed +19
-10
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @module-federation/runtime " : patch
3
+ ---
4
+
5
+ Replaced dynamic module import using ` new Function ` with a safer direct ` import ` call.
6
+
7
+ - Removed usage of ` new Function ` to execute dynamic import
8
+ - Implemented a direct async import with ` /* webpackIgnore: true */ ` for proper bundler handling
Original file line number Diff line number Diff line change @@ -20,11 +20,7 @@ async function loadEsmEntry({
20
20
return new Promise < RemoteEntryExports > ( ( resolve , reject ) => {
21
21
try {
22
22
if ( ! remoteEntryExports ) {
23
- // eslint-disable-next-line no-eval
24
- new Function (
25
- 'callbacks' ,
26
- `import("${ entry } ").then(callbacks[0]).catch(callbacks[1])` ,
27
- ) ( [ resolve , reject ] ) ;
23
+ import ( /* webpackIgnore: true */ entry ) . then ( resolve ) . catch ( reject ) ;
28
24
} else {
29
25
resolve ( remoteEntryExports ) ;
30
26
}
@@ -44,11 +40,16 @@ async function loadSystemJsEntry({
44
40
return new Promise < RemoteEntryExports > ( ( resolve , reject ) => {
45
41
try {
46
42
if ( ! remoteEntryExports ) {
47
- // eslint-disable-next-line no-eval
48
- new Function (
49
- 'callbacks' ,
50
- `System.import("${ entry } ").then(callbacks[0]).catch(callbacks[1])` ,
51
- ) ( [ resolve , reject ] ) ;
43
+ //@ts -ignore
44
+ if ( typeof __system_context__ === 'undefined' ) {
45
+ //@ts -ignore
46
+ System . import ( entry ) . then ( resolve ) . catch ( reject ) ;
47
+ } else {
48
+ new Function (
49
+ 'callbacks' ,
50
+ `System.import("${ entry } ").then(callbacks[0]).catch(callbacks[1])` ,
51
+ ) ( [ resolve , reject ] ) ;
52
+ }
52
53
} else {
53
54
resolve ( remoteEntryExports ) ;
54
55
}
You can’t perform that action at this time.
0 commit comments