File tree Expand file tree Collapse file tree 2 files changed +30
-13
lines changed
Expand file tree Collapse file tree 2 files changed +30
-13
lines changed Original file line number Diff line number Diff line change @@ -39,8 +39,12 @@ export default function(options: $Shape<Options> = {}) {
3939 return wrap ( wasmCode ) . asWebAssembly . Instance ;
4040 case 'module' :
4141 return wrap ( wasmCode ) . asWebAssembly . Module ;
42- case 'promise' :
43- return wrap ( wasmCode ) . promiseWebAssembly ;
42+ case 'promise' || 'async' :
43+ return wrap ( wasmCode ) . promiseWebAssembly . Both ;
44+ case 'async-instance' :
45+ return wrap ( wasmCode ) . promiseWebAssembly . Instance ;
46+ case 'async-module' :
47+ return wrap ( wasmCode ) . promiseWebAssembly . Module ;
4448 }
4549 } else
4650 this . error ( `only support wasm related target compile
Original file line number Diff line number Diff line change @@ -15,20 +15,33 @@ export default function(buffer: Buffer) {
1515 Module :
1616 polyfill +
1717 `export default new WebAssembly.Module(
18- Buffer.from([${ data } ])
19- )` ,
18+ Buffer.from([${ data } ])
19+ )` ,
2020 Instance :
2121 polyfill +
2222 `export default new WebAssembly.Instance(
23- new WebAssembly.Module(
24- Buffer.from([${ data } ])
25- )
26- )`
23+ new WebAssembly.Module(
24+ Buffer.from([${ data } ])
25+ )
26+ )`
2727 } ,
28- promiseWebAssembly :
29- polyfill +
30- `export default WebAssembly.instantiate(
31- Buffer.from([${ data } ])
32- )`
28+ promiseWebAssembly : {
29+ Module :
30+ polyfill +
31+ `module.exports = () => WebAssembly.compile(
32+ Buffer.from([${ data } ])
33+ )` ,
34+ Instance :
35+ polyfill +
36+ `module.exports = importObject => WebAssembly.instantiate(
37+ new WebAssembly.Module(Buffer.from([${ data } ])),
38+ importObject
39+ )` ,
40+ Both :
41+ polyfill +
42+ `module.exports = importObject => WebAssembly.instantiate(
43+ Buffer.from([${ data } ]), importObject
44+ )`
45+ }
3346 } ;
3447}
You can’t perform that action at this time.
0 commit comments