Skip to content

Commit fcc43da

Browse files
committed
Use webpack-hack inside worker_threads
1 parent c685aec commit fcc43da

File tree

1 file changed

+6
-22
lines changed

1 file changed

+6
-22
lines changed

src/worker_threads.ts

+6-22
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,12 @@
1-
// Webpack hack
2-
// tslint:disable no-eval
3-
4-
declare function __non_webpack_require__(module: string): any
5-
6-
// FIXME
7-
type MessagePort = any
8-
9-
interface WorkerThreadsModule {
10-
MessagePort: typeof MessagePort
11-
isMainThread: boolean
12-
parentPort: MessagePort
13-
}
14-
15-
let implementation: WorkerThreadsModule | undefined
1+
// TODO this file isn't used!
162

17-
function selectImplementation(): WorkerThreadsModule {
18-
return typeof __non_webpack_require__ === "function"
19-
? __non_webpack_require__("worker_threads")
20-
: eval("require")("worker_threads")
21-
}
3+
// Webpack hack
4+
import { requireFunction } from './webpack-hack'
225

23-
export default function getImplementation(): WorkerThreadsModule {
6+
let implementation: typeof import("worker_threads") | undefined
7+
export default function getImplementation() {
248
if (!implementation) {
25-
implementation = selectImplementation()
9+
implementation = (requireFunction("worker_threads") as typeof import("worker_threads"))
2610
}
2711
return implementation
2812
}

0 commit comments

Comments
 (0)