Skip to content

Commit 7382333

Browse files
committed
Add isWebpack and requireFunction
1 parent 83d0859 commit 7382333

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/master/implementation.node.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ interface WorkerGlobalScope {
1717
removeEventListener(eventName: string, listener: (event: Event) => void): void
1818
}
1919

20-
declare const __non_webpack_require__: typeof require
20+
// TODO remove webpack hacks. These hurt the performance for non-web-pack situations
21+
// Webpack hack
22+
declare let __non_webpack_require__: typeof require
23+
const isWebpack = typeof __non_webpack_require__ === "function"
24+
const requireFunction: typeof require = isWebpack ? __non_webpack_require__ : eval("require")
25+
2126
declare const self: WorkerGlobalScope
2227

2328
type WorkerEventName = "error" | "message"

0 commit comments

Comments
 (0)