We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 21c8139 commit e928902Copy full SHA for e928902
src/node/index.js
@@ -72,7 +72,7 @@ function Event(type, target) {
72
73
// this module is used self-referentially on both sides of the
74
// thread boundary, but behaves differently in each context.
75
-export default threads.isMainThread ? mainThread() : workerThread();
+export default typeof Worker === 'function' ? Worker : threads.isMainThread ? mainThread() : workerThread();
76
77
const baseUrl = pathToFileURL(process.cwd() + '/');
78
@@ -134,6 +134,10 @@ function mainThread() {
134
}
135
136
function workerThread() {
137
+ // loaded in a real Web Worker (eg: on Electron)
138
+ if (typeof global.WorkerGlobalScope === 'function') {
139
+ return;
140
+ }
141
let { mod, name, type } = threads.workerData;
142
if (!mod) return mainThread();
143
0 commit comments