Skip to content
Snippets Groups Projects
Commit 5a97202d authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

Export the workers as named modules in the webpack build

parent 9c36be18
No related branches found
No related tags found
1 merge request!141npm package config
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// NOTE: wasm_exec.js must always be in the same directory as this script. // 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. // 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) => { const isReady = new Promise((resolve) => {
self.onWasmInitialized = resolve; self.onWasmInitialized = resolve;
......
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// NOTE: wasm_exec.js must always be in the same directory as this script. // 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. // 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) => { const isReady = new Promise((resolve) => {
self.onWasmInitialized = resolve; self.onWasmInitialized = resolve;
......
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// NOTE: wasm_exec.js must always be in the same directory as this script. // 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. // 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) => { const isReady = new Promise((resolve) => {
self.onWasmInitialized = resolve; self.onWasmInitialized = resolve;
......
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// NOTE: wasm_exec.js must always be in the same directory as this script. // 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. // 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) => { const isReady = new Promise((resolve) => {
self.onWasmInitialized = resolve; self.onWasmInitialized = resolve;
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
"src": "src" "src": "src"
}, },
"files": [ "files": [
"src/index.ts",
"dist/*" "dist/*"
], ],
"scripts": { "scripts": {
......
import type { XXDKUtils } from './types'; 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 { declare global {
interface Window extends XXDKUtils { interface Window extends XXDKUtils {
...@@ -22,10 +23,10 @@ export const loadWasm = () => new Promise<void>(async () => { ...@@ -22,10 +23,10 @@ export const loadWasm = () => new Promise<void>(async () => {
// if (typeof window == "undefined") { // if (typeof window == "undefined") {
const go = new window!.Go(); const go = new window!.Go();
let isReady = new Promise((resolve) => { let isReady = new Promise((resolve) => {
window!.onWasmInitialized = resolve; window!.onWasmInitialized = resolve;
}); });
console.log(go); console.log(go);
console.log(xxdk_wasm_path); console.log(xxdk_wasm_path);
console.log("IMPORT"); console.log("IMPORT");
......
const path = require('path'); const path = require('path');
module.exports = { 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', devtool: 'inline-source-map',
mode: 'development', mode: 'development',
output: { output: {
filename: 'bundle.js', filename: '[name].js',
path: path.resolve(__dirname, 'dist'), path: path.resolve(__dirname, 'dist'),
globalObject: 'this', globalObject: 'this',
library: { library: {
...@@ -26,12 +34,12 @@ module.exports = { ...@@ -26,12 +34,12 @@ module.exports = {
test: /\.wasm$/, test: /\.wasm$/,
type: 'asset/resource', type: 'asset/resource',
generator: { generator: {
filename: 'wasm-assets/[hash][ext][query]' filename: 'assets/wasm/[hash][ext][query]'
} }
} }
] ]
}, },
resolve: { resolve: {
extensions: ['.tsx', '.ts', '.js'], extensions: ['.tsx', '.ts', 'js' ],
}, },
}; };
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment