@@ -50,58 +50,24 @@ function generateImportObject(module) {
5050 for ( const pair of depsByRequest ) {
5151 const properties = [ ] ;
5252 for ( const data of pair [ 1 ] ) {
53+ let params = "" ;
54+ let result = "void 0" ;
55+
5356 if ( data . description . type === "FuncImportDescr" ) {
54- const params = data . description . params . map (
57+ params = data . description . params . map (
5558 ( param , k ) => "p" + k + param . valtype
5659 ) ;
5760
58- const result = `__webpack_require__(${ JSON . stringify (
61+ result = `__webpack_require__(${ JSON . stringify (
5962 data . module . id
6063 ) } )[${ JSON . stringify ( data . usedName ) } ](${ params } )`;
61-
62- properties . push (
63- `\n\t\t${ JSON . stringify ( data . exportName ) } : function(${ params } ) {
64- return ${ result } ;
65- }`
66- ) ;
67- }
68-
69- if ( data . description . type === "Memory" ) {
70- const { min, max } = data . description . limits ;
71-
72- const params = {
73- initial : min
74- } ;
75-
76- if ( typeof max === "number" ) {
77- params . maximum = max ;
78- }
79-
80- properties . push (
81- `\n\t\t${ JSON . stringify (
82- data . exportName
83- ) } : new WebAssembly.Memory(${ JSON . stringify ( params ) } )`
84- ) ;
8564 }
8665
87- if ( data . description . type === "Table" ) {
88- const { min, max } = data . description . limits ;
89-
90- const params = {
91- element : data . description . elementType ,
92- initial : min
93- } ;
94-
95- if ( typeof max === "number" ) {
96- params . maximum = max ;
97- }
98-
99- properties . push (
100- `\n\t\t${ JSON . stringify (
101- data . exportName
102- ) } : new WebAssembly.Table(${ JSON . stringify ( params ) } )`
103- ) ;
104- }
66+ properties . push (
67+ `\n\t\t${ JSON . stringify ( data . exportName ) } : function(${ params } ) {
68+ return ${ result } ;
69+ }`
70+ ) ;
10571 }
10672
10773 importsCode . push (
0 commit comments