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;
9
9
10
10
// Without this, ts-loader gets annoyed by imports for the pure type. Clear ts-loader bug,
11
11
// 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';
6
6
declare const promisedValue : Promise < typeof BrotliWasm > ;
7
7
export default promisedValue ;
8
8
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');
3
3
module . exports = nodePkg ;
4
4
5
5
// 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 5
5
// For usage with an importmap, it's convenient to add the ".js" extension here, because browsers
6
6
// don't try to guess the file extension.
7
7
import 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 12
12
"browser" : " ./index.browser.js" ,
13
13
"require" : " ./index.node.js" ,
14
14
"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
+ }
15
33
}
16
34
},
17
35
"sideEffects" : false ,
You can’t perform that action at this time.
0 commit comments