@remix_labs/machine-starter 1.1937.0-dev → 2.1838.0-dev

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/node.js CHANGED
@@ -1,7 +1,31 @@
1
- import Worker from "web-worker";
2
- global.Worker = Worker;
3
- import WT from "worker_threads";
4
- global.MessageChannel = WT.MessageChannel;
5
1
  import Process from "process";
6
2
  global.Process = Process;
7
- export * from "./index.js";
3
+
4
+ // NB: The only way I've made this work in node+webpack is if:
5
+ //
6
+ // * we use Worker from worker_threads directly
7
+ // * we build each worker's module with webpack as an ESM .mjs bundle
8
+ // * we put all the bundles in one directory
9
+ // * we load the worker with a URL('./foo.mjs')
10
+ //
11
+ // Other ways to package/load might work, but definitely seems like
12
+ // using worker_threads.Worker directly is needed (rather than through,
13
+ // say, the web-worker packages that wraps either worker_threads.Worker
14
+ // or the browser Worker to give the same interface). Webpack says ESM
15
+ // is necessary but I'm not sure if this is true for either the main
16
+ // script or the workers.
17
+ import { Worker } from "worker_threads";
18
+
19
+ function GetMachineWASMWorker() {
20
+ return new Worker(new URL("./machine-wasm.mjs", import.meta.url));
21
+ }
22
+ global.GetMachineWASMWorker = GetMachineWASMWorker;
23
+
24
+ // Can't just `export *` because we need hub-client below in common.js
25
+ import * as Hub from "@remix_labs/hub-client";
26
+ export { Hub };
27
+
28
+ import { fileURLToPath } from 'url';
29
+ global.__filename = fileURLToPath(import.meta.url);
30
+
31
+ export * from "./common.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remix_labs/machine-starter",
3
- "version": "1.1937.0-dev",
3
+ "version": "2.1838.0-dev",
4
4
  "description": "start the groove",
5
5
  "main": "node.js",
6
6
  "browser": "index.js",
@@ -11,7 +11,7 @@
11
11
  "author": "Remixlabs staff",
12
12
  "license": "ISC",
13
13
  "dependencies": {
14
- "@remix_labs/hub-client": "1.1937.0-dev",
14
+ "@remix_labs/hub-client": "2.1838.0-dev",
15
15
  "nanoid": "^3.1.12",
16
16
  "web-worker": "^1.2.0"
17
17
  },
package/start.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import Process from "process";
2
- import { StartWASM2 } from "./node.js";
3
- import * as Hub from "@remix_labs/hub-client";
2
+ import { StartWASM2, Hub } from "./node.js";
3
+
4
4
  if (Process.stdout._handle)
5
5
  Process.stdout._handle.setBlocking(true);
6
6
  if (Process.stderr._handle)
@@ -0,0 +1,66 @@
1
+ import path from 'path';
2
+
3
+ import {fileURLToPath} from 'url'
4
+ const __filename = fileURLToPath(import.meta.url);
5
+ const __dirname = path.dirname(__filename);
6
+
7
+ export default [
8
+ {
9
+ name: 'web',
10
+ entry: './index.js',
11
+ mode: "production",
12
+ output: {
13
+ filename: 'machine-starter.js',
14
+ path: path.resolve(__dirname, '../dist')
15
+ },
16
+ optimization: {
17
+ minimize: false
18
+ },
19
+ module: {
20
+ rules: [
21
+ {
22
+ test: /\.worker.js$/,
23
+ type: 'asset/source'
24
+ },
25
+ {
26
+ // Needed for import.meta.url unless we bundle the web workers
27
+ // themselves as separate entries in this bundle.
28
+ test: /\.js$/,
29
+ loader: '@open-wc/webpack-import-meta-loader'
30
+ }
31
+ ]
32
+ }
33
+ },
34
+ {
35
+ name: 'node',
36
+ target: 'node',
37
+ mode: "production",
38
+ entry: {
39
+ node: './start.js',
40
+ },
41
+ optimization: {
42
+ minimize: false,
43
+ },
44
+ module: {
45
+ rules: [
46
+ {
47
+ // Needed for import.meta.url unless we bundle the web workers
48
+ // themselves as separate entries in this bundle.
49
+ test: /\.js$/,
50
+ loader: '@open-wc/webpack-import-meta-loader'
51
+ }
52
+ ]
53
+ },
54
+ experiments: {
55
+ outputModule: true
56
+ },
57
+ output: {
58
+ chunkFormat: 'module',
59
+ filename: 'machine-starter.node.mjs',
60
+ library : {
61
+ type: 'module',
62
+ },
63
+ path: path.resolve(__dirname, '../dist'),
64
+ }
65
+ }
66
+ ]