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

Changes to make the module load properly

parent 4435730c
Branches
Tags
1 merge request!141npm package config
......@@ -2,7 +2,8 @@
"name": "xxdk-wasm",
"version": "0.3.9",
"description": "WebAssembly bindings for xxDK.",
"module": "src/index.ts",
"main": "dist/bundle.js",
"module": "dist/bundle.js",
"directories": {
"test": "test",
"src": "src"
......
......@@ -4,15 +4,21 @@ declare global {
interface Window extends XXDKUtils {}
}
import '../wasm_exec';
// @ts-ignore
import makeWasm from '../xxdk.wasm';
// import makeWasm from '../xxdk.wasm';
export const loadUtils = () => new Promise<XXDKUtils>(async (res) => {
const go = new (window as any).Go();
const result = await makeWasm(go.importObject);
go.run(result.instance);
const Go = require('../wasm_exec');
const go = new Go();
let mod, inst;
WebAssembly.instantiateStreaming(fetch("../xxdk.wasm"), go.importObject).then(async (result) => {
mod = result.module;
inst = result.instance;
await go.run(inst);
inst = await WebAssembly.instantiate(mod, go.importObject); // reset instance
}).catch((err) => {
console.error(err);
});
const {
Base64ToUint8Array,
......
......@@ -11,6 +11,7 @@ module.exports = {
name: 'xxdk-wasm',
type: 'umd',
},
publicPath: '',
},
module: {
rules: [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment