Skip to content

Commit c90c5fa

Browse files
authored
Add the global polyfill (#1500)
1 parent eec5b71 commit c90c5fa

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

webworker/entrypoint.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ import { setValueAtPath } from "lib/shared/obj-path"
2222
globalThis.React = React
2323
setupFetchProxy()
2424

25+
// Polyfill for Node.js global object in browser workers
26+
// Needed because @tscircuit/core and dependencies reference global.debugGraphics/debugOutputArray
27+
globalThis.global = globalThis.global || globalThis
28+
2529
let executionContext: ExecutionContext | null = null
2630
let debugNamespace: string | undefined
2731

@@ -196,7 +200,7 @@ const webWorkerApi = {
196200
let element: any
197201
if (typeof component === "function") {
198202
element = component()
199-
} else if (component && component.__isSerializedReactElement) {
203+
} else if (component?.__isSerializedReactElement) {
200204
element = deserializeReactElement(component)
201205
} else {
202206
element = component

0 commit comments

Comments
 (0)