diff --git a/assets/jsutils/channelsIndexedDbWorker.js b/assets/jsutils/channelsIndexedDbWorker.js index f37ab6a4350022119c883c17f39467b5e029edef..f3ca2dc573bff03fdc156614aa8d9ea6b02128bc 100644 --- a/assets/jsutils/channelsIndexedDbWorker.js +++ b/assets/jsutils/channelsIndexedDbWorker.js @@ -6,9 +6,9 @@ //////////////////////////////////////////////////////////////////////////////// // NOTE: wasm_exec.js must always be in the same directory as this script. -importScripts('wasm_exec.js'); +importScripts(require('./wasm_exec.js')); // NOTE: This relative path must be preserved in distribution. -const binPath = '../wasm/xxdk-channelsIndexedDkWorker.wasm' +const binPath = require('../wasm/xxdk-channelsIndexedDkWorker.wasm'); const isReady = new Promise((resolve) => { self.onWasmInitialized = resolve; diff --git a/assets/jsutils/dmIndexedDbWorker.js b/assets/jsutils/dmIndexedDbWorker.js index 5605dba77cd1316f13f8bf13cd7c54064430bd81..56819be8a3ededdfb33ad07ab040db8b8fd38ba2 100644 --- a/assets/jsutils/dmIndexedDbWorker.js +++ b/assets/jsutils/dmIndexedDbWorker.js @@ -6,9 +6,9 @@ //////////////////////////////////////////////////////////////////////////////// // NOTE: wasm_exec.js must always be in the same directory as this script. -importScripts('wasm_exec.js'); +importScripts(require('./wasm_exec.js')); // NOTE: This relative path must be preserved in distribution. -const binPath = '../wasm/xxdk-dmIndexedDkWorker.wasm' +const binPath = require('../wasm/xxdk-dmIndexedDkWorker.wasm'); const isReady = new Promise((resolve) => { self.onWasmInitialized = resolve; diff --git a/assets/jsutils/logFileWorker.js b/assets/jsutils/logFileWorker.js index 1ef114bb6bc1b33f8f26703119f15aa044c7f61d..5f8f31f960d309db7c6e1b1b031e68114759a64a 100644 --- a/assets/jsutils/logFileWorker.js +++ b/assets/jsutils/logFileWorker.js @@ -6,9 +6,9 @@ //////////////////////////////////////////////////////////////////////////////// // NOTE: wasm_exec.js must always be in the same directory as this script. -importScripts('wasm_exec.js'); +importScripts(require('./wasm_exec.js')); // NOTE: This relative path must be preserved in distribution. -const binPath = '../wasm/xxdk-logFileWorker.wasm' +const binPath = require('../wasm/xxdk-logFileWorker.wasm'); const isReady = new Promise((resolve) => { self.onWasmInitialized = resolve; diff --git a/assets/jsutils/stateIndexedDbWorker.js b/assets/jsutils/stateIndexedDbWorker.js index b4009ef36f9e1db375578fb759a2a8a53cf44b5b..091564b1294bc6eb0232a9de7bc5e5ddf53cd76a 100644 --- a/assets/jsutils/stateIndexedDbWorker.js +++ b/assets/jsutils/stateIndexedDbWorker.js @@ -6,9 +6,9 @@ //////////////////////////////////////////////////////////////////////////////// // NOTE: wasm_exec.js must always be in the same directory as this script. -importScripts('wasm_exec.js'); +importScripts(require('./wasm_exec.js')); // NOTE: This relative path must be preserved in distribution. -const binPath = '../wasm/xxdk-stateIndexedDkWorker.wasm' +const binPath = require('../wasm/xxdk-stateIndexedDkWorker.wasm'); const isReady = new Promise((resolve) => { self.onWasmInitialized = resolve; diff --git a/package.json b/package.json index 798ebe626e744567a6e4c78d1d85542c6bae1afb..753d8974ed3e8a370894c1b4c1257bd2d3d43949 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,6 @@ "src": "src" }, "files": [ - "src/index.ts", "dist/*" ], "scripts": { diff --git a/src/index.ts b/src/index.ts index 39e27370ea2de2afce48f7351b3d41ad332c8e3e..dde5e7fe62c575afc519743fc9c8453f80866bb3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,8 +1,9 @@ import type { XXDKUtils } from './types'; -import '../wasm_exec.js'; +import('../assets/jsutils/wasm_exec.js'); -const xxdkWasm: URL = require('../xxdk.wasm'); + +const xxdkWasm: URL = require('../assets/wasm/xxdk.wasm'); declare global { interface Window extends XXDKUtils { @@ -22,10 +23,10 @@ export const loadWasm = () => new Promise<void>(async () => { // if (typeof window == "undefined") { const go = new window!.Go(); - let isReady = new Promise((resolve) => { window!.onWasmInitialized = resolve; }); + console.log(go); console.log(xxdk_wasm_path); console.log("IMPORT"); diff --git a/webpack.config.js b/webpack.config.js index 7944eec4d612aaaaf8e3ee0f908bdeceb23a5f17..fe82740d7971fd5a2c8438df3f69cce4e6f32d07 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,11 +1,19 @@ const path = require('path'); module.exports = { - entry: './src/index.ts', + entry: { + bundle: './src/index.ts', + logFileWorker: './assets/jsutils/logFileWorker.js', + channelsIndexDbWorker: './assets/jsutils/channelsIndexedDbWorker.js', + dmIndexedDbWorker: './assets/jsutils/dmIndexedDbWorker.js', + ndf: './assets/jsutils/ndf.js', + stateIndexedDbWorker: './assets/jsutils/stateIndexedDbWorker.js', + wasm_exec: './assets/jsutils/wasm_exec.js', + }, devtool: 'inline-source-map', mode: 'development', output: { - filename: 'bundle.js', + filename: '[name].js', path: path.resolve(__dirname, 'dist'), globalObject: 'this', library: { @@ -26,12 +34,12 @@ module.exports = { test: /\.wasm$/, type: 'asset/resource', generator: { - filename: 'wasm-assets/[hash][ext][query]' + filename: 'assets/wasm/[hash][ext][query]' } } ] }, resolve: { - extensions: ['.tsx', '.ts', '.js'], + extensions: ['.tsx', '.ts', 'js' ], }, };