@@ -68,27 +68,6 @@ function optPassSimplifyModularizeFunction(ast) {
68
68
} ) ;
69
69
}
70
70
71
- // Closure integration of the Module object generates an awkward "var b; b || (b = Module);" code.
72
- // 'b || (b = Module)' -> 'b = Module'.
73
- function optPassSimplifyModuleInitialization ( ast ) {
74
- visitNodes ( ast , [ 'BlockStatement' , 'Program' ] , ( node ) => {
75
- for ( const n of node . body ) {
76
- if (
77
- n . type == 'ExpressionStatement' &&
78
- n . expression . type == 'LogicalExpression' &&
79
- n . expression . operator == '||' &&
80
- n . expression . left . name === n . expression . right . left ?. name &&
81
- n . expression . right . right . name == 'Module'
82
- ) {
83
- // Clear out the logical operator.
84
- n . expression = n . expression . right ;
85
- // There is only one Module assignment, so can finish the pass here.
86
- return false ;
87
- }
88
- }
89
- } ) ;
90
- }
91
-
92
71
// Finds redundant operator new statements that are not assigned anywhere.
93
72
// (we aren't interested in side effects of the calls if no assignment)
94
73
function optPassRemoveRedundantOperatorNews ( ast ) {
@@ -225,7 +204,6 @@ function optPassMergeVarInitializationAssignments(ast) {
225
204
function runOnJsText ( js , pretty = false ) {
226
205
const ast = acorn . parse ( js , { ecmaVersion : 2021 } ) ;
227
206
228
- optPassSimplifyModuleInitialization ( ast ) ;
229
207
optPassRemoveRedundantOperatorNews ( ast ) ;
230
208
231
209
let progress = true ;
@@ -273,10 +251,6 @@ function runTests() {
273
251
'var Module=function(f){};' ,
274
252
) ;
275
253
276
- // optPassSimplifyModuleInitialization:
277
- test ( 'b || (b = Module);' , 'b=Module;' ) ;
278
- test ( 'function foo(){b || (b = Module);}' , 'function foo(){b=Module}' ) ;
279
-
280
254
// optPassRemoveRedundantOperatorNews:
281
255
test ( 'new Uint16Array(a);' , '' ) ;
282
256
test ( 'new Uint16Array(a),new Uint16Array(a);' , ';' ) ;
0 commit comments