File tree Expand file tree Collapse file tree 2 files changed +3
-8
lines changed
Expand file tree Collapse file tree 2 files changed +3
-8
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,6 @@ const Generator = require("../Generator");
88const { RawSource } = require ( "webpack-sources" ) ;
99
1010const { editWithAST, addWithAST } = require ( "@webassemblyjs/wasm-edit" ) ;
11- const { decode } = require ( "@webassemblyjs/wasm-parser" ) ;
1211const t = require ( "@webassemblyjs/ast" ) ;
1312
1413function compose ( ...fns ) {
@@ -244,15 +243,9 @@ const addInitFunction = ({
244243
245244class WebAssemblyGenerator extends Generator {
246245 generate ( module ) {
246+ const ast = module . _ast ;
247247 const bin = module . originalSource ( ) . source ( ) ;
248248
249- // FIXME(sven): this module is parsed twice, we could preserve the AST
250- // from wasm/WebAssemblyParser.js
251- const ast = decode ( bin , {
252- ignoreDataSection : true ,
253- ignoreCodeSection : true
254- } ) ;
255-
256249 const importedGlobals = getImportedGlobals ( ast ) ;
257250 const countImportedFunc = getCountImportedFunc ( ast ) ;
258251 const startAtFuncIndex = getStartFuncIndex ( ast ) ;
Original file line number Diff line number Diff line change @@ -73,6 +73,8 @@ class WebAssemblyParser extends Tapable {
7373 }
7474 } ) ;
7575
76+ state . module . _ast = ast ;
77+
7678 return state ;
7779 }
7880}
You can’t perform that action at this time.
0 commit comments