File tree Expand file tree Collapse file tree 5 files changed +49
-4
lines changed Expand file tree Collapse file tree 5 files changed +49
-4
lines changed Original file line number Diff line number Diff line change @@ -9,4 +9,8 @@ module.exports.default = module.exports;
99
1010// Without this, ts-loader gets annoyed by imports for the pure type. Clear ts-loader bug,
1111// but this is a quick & easy fix on our end:
12- module . exports . BrotliWasmType = undefined ;
12+ module . exports . BrotliWasmType = undefined ;
13+
14+ module . exports . init = ( _ ) => {
15+ return globalThis . Promise . resolve ( ) ;
16+ }
Original file line number Diff line number Diff line change @@ -6,4 +6,21 @@ export * from './pkg.node/brotli_wasm';
66declare const promisedValue : Promise < typeof BrotliWasm > ;
77export default promisedValue ;
88
9- export type BrotliWasmType = typeof BrotliWasm ;
9+ export type BrotliWasmType = typeof BrotliWasm ;
10+
11+ import type { InitInput , InitOutput } from './pkg.web/brotli_wasm' ;
12+
13+ /**
14+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
15+ * for everything else, calls `WebAssembly.instantiate` directly.
16+ *
17+ * If this project's target is `cloudflare-workers`, you must use this.
18+ * If you use web, this function will return a promise that resolves to the
19+ * `BrotliWasm` module, which you can use directly.
20+ * But if you use other targets, this function will return the void type.
21+ *
22+ * @param {InitInput | Promise<InitInput> } module_or_path
23+ *
24+ * @returns {Promise<InitOutput> }
25+ */
26+ export function init ( module_or_path ?: InitInput | Promise < InitInput > ) : Promise < InitOutput | void > ;
Original file line number Diff line number Diff line change @@ -3,4 +3,8 @@ const nodePkg = require('./pkg.node/brotli_wasm');
33module . exports = nodePkg ;
44
55// In addition though, we provide a default export, to match the pure ESM web bundle:
6- module . exports . default = Promise . resolve ( nodePkg ) ;
6+ module . exports . default = Promise . resolve ( nodePkg ) ;
7+
8+ module . exports . init = ( _ ) => {
9+ return globalThis . Promise . resolve ( ) ;
10+ }
Original file line number Diff line number Diff line change 55// For usage with an importmap, it's convenient to add the ".js" extension here, because browsers
66// don't try to guess the file extension.
77import init , * as brotliWasm from "./pkg.web/brotli_wasm.js" ;
8- export default init ( ) . then ( ( ) => brotliWasm ) ;
8+ export default init ( ) . then ( ( ) => brotliWasm ) ;
9+
10+ export { init } ;
Original file line number Diff line number Diff line change 1212 "browser" : " ./index.browser.js" ,
1313 "require" : " ./index.node.js" ,
1414 "default" : " ./index.web.js"
15+ },
16+ "./wasm" : {
17+ "import" : {
18+ "types" : " ./pkg.web/brotli_wasm_bg.wasm.d.ts" ,
19+ "default" : " ./pkg.web/brotli_wasm_bg.wasm"
20+ },
21+ "browser" : {
22+ "types" : " ./pkg.bundler/brotli_wasm_bg.wasm.d.ts" ,
23+ "default" : " ./pkg.bundler/brotli_wasm_bg.wasm"
24+ },
25+ "require" : {
26+ "types" : " ./pkg.node/brotli_wasm_bg.wasm.d.ts" ,
27+ "default" : " ./pkg.node/brotli_wasm_bg.wasm"
28+ },
29+ "default" : {
30+ "types" : " ./pkg.web/brotli_wasm_bg.wasm.d.ts" ,
31+ "default" : " ./pkg.web/brotli_wasm_bg.wasm"
32+ }
1533 }
1634 },
1735 "sideEffects" : false ,
You can’t perform that action at this time.
0 commit comments