Skip to content

Commit f2516f6

Browse files
committed
feat(wasm-mps): add --target web build for browser-safe WASM init
Add dist/web/js/wasm Makefile target using wasm-pack --target web, which generates a single ESM file with an explicit async init() default export. This avoids the webpack asyncWebAssembly race where __wbg_set_wasm may not be called before exports are used. Update package.json to include dist/web/js/**/* in published files, expose the ./web subpath export pointing to the generated entry point, and add make dist/web/js/wasm to the build:wasm script. Ticket: WCI-250
1 parent 75ccf91 commit f2516f6

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

packages/wasm-mps/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ dist/esm/js/wasm:
6464
dist/cjs/js/wasm:
6565
$(call BUILD,$@,nodejs)
6666

67+
.PHONY: dist/web/js/wasm
68+
dist/web/js/wasm:
69+
$(call BUILD,$@,web)
70+
6771
.PHONY: lint
6872
lint:
6973
cargo fmt --check

packages/wasm-mps/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"files": [
1212
"dist/esm/js/**/*",
1313
"dist/cjs/js/**/*",
14+
"dist/web/js/**/*",
1415
"dist/cjs/package.json"
1516
],
1617
"exports": {
@@ -23,7 +24,8 @@
2324
"types": "./dist/cjs/js/index.d.ts",
2425
"default": "./dist/cjs/js/index.js"
2526
}
26-
}
27+
},
28+
"./web": "./dist/web/js/wasm/wasm_mps.js"
2729
},
2830
"main": "./dist/cjs/js/index.js",
2931
"module": "./dist/esm/js/index.js",
@@ -35,7 +37,7 @@
3537
"scripts": {
3638
"test": "npm run test:mocha",
3739
"test:mocha": "mocha --recursive test",
38-
"build:wasm": "make js/wasm && make dist/esm/js/wasm && make dist/cjs/js/wasm",
40+
"build:wasm": "make js/wasm && make dist/esm/js/wasm && make dist/cjs/js/wasm && make dist/web/js/wasm",
3941
"build:ts-esm": "tsc",
4042
"build:ts-cjs": "tsc --project tsconfig.cjs.json",
4143
"build:ts": "npm run build:ts-esm && npm run build:ts-cjs",

0 commit comments

Comments
 (0)