Skip to content

Commit d267b58

Browse files
committed
Add an async browser wrapper for easier webpack usage
1 parent 39f18e4 commit d267b58

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

index.browser.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// This makes importing wasm-brotli asynchronous (because of dynamic import).
2+
// This is needed here for Webpack v4 or v5 syncWebAssembly, which don't
3+
// allow synchronous import of WebAssembly from an entrypoint.
4+
module.exports = import("./pkg.bundler/brotli_wasm.js");
5+
6+
// We don't want to do this for _all_ usage, because dynamic import isn't
7+
// supported in older node versions.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "A compressor and decompressor for Brotli that actually works, for node & browsers",
55
"main": "./pkg.node/brotli_wasm.js",
66
"types": "./pkg.node/brotli_wasm.d.ts",
7-
"browser": "./pkg.bundler/brotli_wasm.js",
7+
"browser": "./index.browser.js",
88
"sideEffects": false,
99
"scripts": {
1010
"build": "node ./build.js",

0 commit comments

Comments
 (0)