Skip to content

Commit c920ff6

Browse files
fix(runtime): support restricted unsafe-eval environments
1 parent dae58e8 commit c920ff6

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/runtime/src/global.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,14 @@ export interface Federation {
2222
__PRELOADED_MAP__: Map<string, boolean>;
2323
}
2424

25-
// export const nativeGlobal: typeof global = new Function('return this')();
26-
export const nativeGlobal: typeof global = new Function('return this')();
25+
export const nativeGlobal: typeof global = (() => {
26+
try {
27+
return new Function('return this');
28+
} catch {
29+
return globalThis;
30+
}
31+
})() as typeof global;
32+
2733
export const Global = nativeGlobal;
2834

2935
declare global {

0 commit comments

Comments
 (0)