napi-rs / napi-rs/package-template
Browser Support / Wasm Threading & Cross-Origin Isolation (COI) Failure
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 372
- Forks
- 45
- Avg merge
- 3m
- Merged PRs (30d)
- 1
Description
Hello team,
We are using your NAPI-RS Wasm module and face two major blockers for browser SDK usage:
1. Wasm Threading Requires Unfeasible Server Configuration
The module's use of Wasm Threads/SharedArrayBuffer forces the browser to require Cross-Origin Isolation (COI).
Error: DataCloneError: SharedArrayBuffer transfer requires self.crossOriginIsolated.
Impact: This imposes a mandatory COOP/COEP HTTP header setup on all end-users, which is unacceptable for a public SDK.
2. Packaging/Loading Failure
Standard bundlers (Vite/Webpack) fail to reliably resolve and load the necessary Wasm binary and its Worker script in the browser environment.
Request for Seamless Browser Solution
We need an official strategy to eliminate these deployment blockers. Please provide guidance or a configuration change for NAPI-RS to support one of the following:
A. Max Compatibility Build (No COI Required):
Goal: A non-threaded Wasm build that uses traditional data transfer, allowing the module to work out-of-the-box in any browser environment (no COOP/COEP required).
B. Improved Threaded Distribution:
Goal: A packaging solution that makes the Wasm binary and Worker files seamlessly resolvable by common bundlers, even if COOP/COEP is still required.
Your help in making this module browser-friendly is appreciated.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the browser failures with the Wasm module under Vite and Webpack, checking COI behavior and resolution of the Wasm binary and Worker script. Done means an agreed official strategy is documented or implemented for a non-threaded build or reliable threaded packaging, with browser loading verified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- vite, wasm, webpack
- Domain
- build-system, web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100