Skip to content

Commit

Permalink
fix(runtime): support restricted unsafe-eval environments
Browse files Browse the repository at this point in the history
  • Loading branch information
ScriptedAlchemy committed Jan 24, 2024
1 parent dae58e8 commit 78eb512
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/runtime/src/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,14 @@ export interface Federation {
__PRELOADED_MAP__: Map<string, boolean>;
}

// export const nativeGlobal: typeof global = new Function('return this')();
export const nativeGlobal: typeof global = new Function('return this')();
function returnGlobal() {
try {
return new Function('return this');
} catch {
return globalThis;
}
}
export const nativeGlobal: typeof global = returnGlobal() as typeof global;
export const Global = nativeGlobal;

declare global {
Expand Down

0 comments on commit 78eb512

Please sign in to comment.