@@ -54,7 +54,7 @@ export async function generateWasmSyncWrapper(options) {
5454 outputSyncJs,
5555 packageName,
5656 wasmFile,
57- } = options
57+ } = { __proto__ : null , ... options }
5858
5959 if ( ! existsSync ( wasmFile ) ) {
6060 throw new Error ( `WASM file not found: ${ wasmFile } ` )
@@ -116,19 +116,19 @@ export async function generateWasmSyncWrapper(options) {
116116 s = new MagicString ( mjsContent )
117117
118118 // Helpers: Safe transformations for minified code (may have overlapping mods)
119- const safeRemove = ( start , end ) => {
119+ const safeOverwrite = ( start , end , content ) => {
120120 try {
121- s . remove ( start , end )
121+ s . overwrite ( start , end , content )
122122 } catch {
123- // Minified code - skip conflicting removes, leave as dead code
123+ // Minified code - skip conflicting overwrites
124124 }
125125 }
126126
127- const safeOverwrite = ( start , end , content ) => {
127+ const safeRemove = ( start , end ) => {
128128 try {
129- s . overwrite ( start , end , content )
129+ s . remove ( start , end )
130130 } catch {
131- // Minified code - skip conflicting overwrites
131+ // Minified code - skip conflicting removes, leave as dead code
132132 }
133133 }
134134
@@ -141,19 +141,16 @@ export async function generateWasmSyncWrapper(options) {
141141 // 5. Remove top-level statements that fetch/load WASM asynchronously
142142
143143 const topLevelStatementsToRemove = [ ]
144- const _variableDeclaratorsToRemove = [ ]
145144 const requireDeclaratorsToRemove = [ ]
146145 const returnModuleToFix = [ ]
147146 // Track functions that need WebAssembly.instantiate replacement
148147 const functionsToGut = [ ]
149- let _exportDefaultFound = false
150148 let exportDefaultIndex = - 1
151149
152150 traverse ( ast , {
153151 // Remove ALL export statements (convert ESM to CommonJS)
154152 ExportDefaultDeclaration ( path ) {
155153 if ( path . parent . type === 'Program' ) {
156- _exportDefaultFound = true
157154 // Find the index of this export in the program body
158155 const programBody = path . parent . body
159156 exportDefaultIndex = programBody . indexOf ( path . node )
0 commit comments