File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -53,23 +53,18 @@ function generateImportObject(module) {
5353 for ( const pair of depsByRequest ) {
5454 const properties = [ ] ;
5555 for ( const data of pair [ 1 ] ) {
56- let params = "" ;
57- let result = "void 0" ;
58-
59- if ( data . description . type === "FuncImportDescr" ) {
60- params = data . description . params . map (
61- ( param , k ) => "p" + k + param . valtype
62- ) ;
56+ const params = data . description . params . map (
57+ ( param , k ) => "p" + k + param . valtype
58+ ) ;
6359
64- result = `__webpack_require__(${ JSON . stringify (
65- data . module . id
66- ) } )[${ JSON . stringify ( data . usedName ) } ](${ params } )`;
67- }
60+ const result = `__webpack_require__(${ JSON . stringify (
61+ data . module . id
62+ ) } )[${ JSON . stringify ( data . usedName ) } ](${ params } )`;
6863
6964 properties . push (
7065 `\n\t\t${ JSON . stringify ( data . exportName ) } : function(${ params } ) {
71- return ${ result } ;
72- }`
66+ return ${ result } ;
67+ }`
7368 ) ;
7469 }
7570
Original file line number Diff line number Diff line change @@ -10,11 +10,21 @@ const { decode } = require("@webassemblyjs/wasm-parser");
1010const { Tapable } = require ( "tapable" ) ;
1111const WebAssemblyImportDependency = require ( "./dependencies/WebAssemblyImportDependency" ) ;
1212
13+ const isMemoryImport = moduleImport => moduleImport . descr . type === "Memory" ;
14+ const isTableImport = moduleImport => moduleImport . descr . type === "Table" ;
15+
1316const decoderOpts = {
1417 ignoreCodeSection : true ,
1518 ignoreDataSection : true
1619} ;
1720
21+ function nonSupportImportOfType ( type ) {
22+ const e = new Error ( "Unsupported import of type " + JSON . stringify ( type ) ) ;
23+ e . stack = "" ;
24+
25+ return e ;
26+ }
27+
1828class WebAssemblyParser extends Tapable {
1929 constructor ( options ) {
2030 super ( ) ;
@@ -37,6 +47,16 @@ class WebAssemblyParser extends Tapable {
3747 } ,
3848
3949 ModuleImport ( { node } ) {
50+ // Prevent importing a Memory or Table for now
51+ // Depends on https://github.com/WebAssembly/esm-integration
52+ if ( isMemoryImport ( node ) === true ) {
53+ throw nonSupportImportOfType ( "Memory" ) ;
54+ }
55+
56+ if ( isTableImport ( node ) === true ) {
57+ throw nonSupportImportOfType ( "Table" ) ;
58+ }
59+
4060 const dep = new WebAssemblyImportDependency (
4161 node . module ,
4262 node . name ,
You can’t perform that action at this time.
0 commit comments