@@ -89,7 +89,7 @@ export async function componentize(
89
89
90
90
let {
91
91
sourceName = 'source.js' ,
92
- sourcePath = join ( sourceDir , sourceName ) ,
92
+ sourcePath = join ( sourcesDir , sourceName ) ,
93
93
preview2Adapter = preview1AdapterReactorPath ( ) ,
94
94
witPath,
95
95
witWorld,
@@ -100,9 +100,7 @@ export async function componentize(
100
100
runtimeArgs,
101
101
debugBindings = false ,
102
102
enableWizerLogging = false ,
103
- aotCache = fileURLToPath (
104
- new URL ( `../lib/starlingmonkey_ics.wevalcache` , import . meta. url ) ,
105
- ) ,
103
+ aotCache = DEFAULT_AOT_CACHE ,
106
104
} = opts ;
107
105
108
106
// Determine the path to the StarlingMonkey binary
@@ -191,7 +189,7 @@ export async function componentize(
191
189
console . log ( env ) ;
192
190
}
193
191
194
- let initializerPath = join ( sourceDir , 'initializer.js' ) ;
192
+ let initializerPath = join ( sourcesDir , 'initializer.js' ) ;
195
193
sourcePath = maybeWindowsPath ( sourcePath ) ;
196
194
let workspacePrefix = dirname ( sourcePath ) ;
197
195
@@ -202,7 +200,7 @@ export async function componentize(
202
200
// support --mapdir.
203
201
if ( ! opts . enableAot ) {
204
202
if ( ! useOriginalSourceFile ) {
205
- workspacePrefix = sourceDir ;
203
+ workspacePrefix = sourcesDir ;
206
204
sourcePath = sourceName ;
207
205
}
208
206
if ( workspacePrefix . startsWith ( cwd ( ) ) ) {
@@ -212,7 +210,7 @@ export async function componentize(
212
210
}
213
211
let args = `--initializer-script-path ${ initializerPath } --strip-path-prefix ${ workspacePrefix } / ${ sourcePath } ` ;
214
212
runtimeArgs = runtimeArgs ? `${ runtimeArgs } ${ args } ` : args ;
215
- let preopens = [ `--dir ${ sourceDir } ` ] ;
213
+ let preopens = [ `--dir ${ sourcesDir } ` ] ;
216
214
if ( opts . enableAot ) {
217
215
preopens . push ( `--dir ${ workspacePrefix } ` ) ;
218
216
} else {
@@ -251,8 +249,8 @@ export async function componentize(
251
249
'-w' ,
252
250
'--init-func' ,
253
251
'componentize.wizer' ,
254
- `-i ${ input } ` ,
255
- `-o ${ output } ` ,
252
+ `-i ${ inputWasmPath } ` ,
253
+ `-o ${ outputWasmPath } ` ,
256
254
] ,
257
255
{
258
256
stdio : [ null , stdout , 'pipe' ] ,
@@ -272,8 +270,8 @@ export async function componentize(
272
270
...preopens ,
273
271
`--wasm-bulk-memory=true` ,
274
272
'--inherit-env=true' ,
275
- `-o=${ output } ` ,
276
- input ,
273
+ `-o=${ outputWasmPath } ` ,
274
+ inputWasmPath ,
277
275
] ,
278
276
{
279
277
stdio : [ null , stdout , 'pipe' ] ,
@@ -291,16 +289,16 @@ export async function componentize(
291
289
if ( debugBindings ) {
292
290
err += `\n\nBinary and sources available for debugging at ${ tmpDir } \n` ;
293
291
} else {
294
- rmSync ( tmpDir , { recursive : true } ) ;
292
+ await rm ( workDir , { recursive : true } ) ;
295
293
}
296
294
throw new Error ( err ) ;
297
295
}
298
296
297
+ // Read the generated WASM back into memory
299
298
const bin = await readFile ( outputWasmPath ) ;
300
299
301
- // Check for initialization errors
302
- // By actually executing the binary in a mini sandbox to get back
303
- // the initialization state
300
+ // Check for initialization errors, by actually executing the binary in
301
+ // a mini sandbox to get back the initialization state
304
302
const {
305
303
exports : { check_init } ,
306
304
getStderr,
0 commit comments