bare-worker 4.1.4 → 4.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/preloads.js +3 -9
- package/lib/worker-thread.js +7 -1
- package/package.json +1 -1
package/lib/preloads.js
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
const
|
|
1
|
+
const WorkerState = require('./worker-state')
|
|
2
2
|
|
|
3
3
|
const preloads = new Map()
|
|
4
4
|
|
|
5
|
-
if (
|
|
6
|
-
|
|
7
|
-
typeof Thread.self.data === 'object' &&
|
|
8
|
-
Thread.self.data !== null &&
|
|
9
|
-
typeof Thread.self.data.preloads === 'object' &&
|
|
10
|
-
Thread.self.data.preloads !== null
|
|
11
|
-
) {
|
|
12
|
-
for (const [entry, source] of Thread.self.data.preloads) {
|
|
5
|
+
if (WorkerState.parent) {
|
|
6
|
+
for (const [entry, source] of WorkerState.parent.preloads) {
|
|
13
7
|
preloads.set(entry, source)
|
|
14
8
|
}
|
|
15
9
|
}
|
package/lib/worker-thread.js
CHANGED
|
@@ -10,7 +10,13 @@ Bare.on('newListener', onnewlistener)
|
|
|
10
10
|
|
|
11
11
|
const cache = Object.create(null)
|
|
12
12
|
|
|
13
|
-
for (const [
|
|
13
|
+
for (const [, source] of state.preloads) {
|
|
14
|
+
Module.load(
|
|
15
|
+
new URL(`bare:/worker/preload-${Math.random().toString(16).slice(2)}.bundle`),
|
|
16
|
+
source,
|
|
17
|
+
{ cache }
|
|
18
|
+
)
|
|
19
|
+
}
|
|
14
20
|
|
|
15
21
|
Module.load(new URL('bare:/worker.bundle'), state.source, { cache })
|
|
16
22
|
|