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 CHANGED
@@ -1,15 +1,9 @@
1
- const Thread = require('bare-thread')
1
+ const WorkerState = require('./worker-state')
2
2
 
3
3
  const preloads = new Map()
4
4
 
5
- if (
6
- Thread.self &&
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
  }
@@ -10,7 +10,13 @@ Bare.on('newListener', onnewlistener)
10
10
 
11
11
  const cache = Object.create(null)
12
12
 
13
- for (const [entry, source] of state.preloads) Module.load(new URL(entry), source, { cache })
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-worker",
3
- "version": "4.1.4",
3
+ "version": "4.1.5",
4
4
  "description": "Higher-level worker threads for JavaScript",
5
5
  "exports": {
6
6
  ".": "./index.js",