Skip to content

Commit

Permalink
prevent compiled output blowing up in Node if window is not defined
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris authored and Conduitry committed Jun 12, 2019
1 parent f60ae53 commit 788cf97
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/runtime/internal/globals.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const win = typeof window !== 'undefined' ? window : global;

const {
// ecmascript
Error,
Expand All @@ -15,9 +17,8 @@ const {
getComputedStyle,
navigator,
requestAnimationFrame,
setTimeout: export_setTimeout, // TODO: remove when upgrading typescript, bug
window: export_window,
} = (window || global) as unknown as typeof globalThis;
setTimeout: export_setTimeout // TODO: remove when upgrading typescript, bug
} = win as unknown as typeof globalThis;

export {
// ecmascript
Expand All @@ -37,5 +38,5 @@ export {
navigator,
requestAnimationFrame,
export_setTimeout as setTimeout,
export_window as window,
win as window,
};

0 comments on commit 788cf97

Please sign in to comment.