Skip to content

Commit 85184f5

Browse files
refactor: fixup
Signed-off-by: Victor Adossi <[email protected]>
1 parent a2720ef commit 85184f5

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

src/componentize.js

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export async function componentize(
8989

9090
let {
9191
sourceName = 'source.js',
92-
sourcePath = join(sourceDir, sourceName),
92+
sourcePath = join(sourcesDir, sourceName),
9393
preview2Adapter = preview1AdapterReactorPath(),
9494
witPath,
9595
witWorld,
@@ -100,9 +100,7 @@ export async function componentize(
100100
runtimeArgs,
101101
debugBindings = false,
102102
enableWizerLogging = false,
103-
aotCache = fileURLToPath(
104-
new URL(`../lib/starlingmonkey_ics.wevalcache`, import.meta.url),
105-
),
103+
aotCache = DEFAULT_AOT_CACHE,
106104
} = opts;
107105

108106
// Determine the path to the StarlingMonkey binary
@@ -191,7 +189,7 @@ export async function componentize(
191189
console.log(env);
192190
}
193191

194-
let initializerPath = join(sourceDir, 'initializer.js');
192+
let initializerPath = join(sourcesDir, 'initializer.js');
195193
sourcePath = maybeWindowsPath(sourcePath);
196194
let workspacePrefix = dirname(sourcePath);
197195

@@ -202,7 +200,7 @@ export async function componentize(
202200
// support --mapdir.
203201
if (!opts.enableAot) {
204202
if (!useOriginalSourceFile) {
205-
workspacePrefix = sourceDir;
203+
workspacePrefix = sourcesDir;
206204
sourcePath = sourceName;
207205
}
208206
if (workspacePrefix.startsWith(cwd())) {
@@ -212,7 +210,7 @@ export async function componentize(
212210
}
213211
let args = `--initializer-script-path ${initializerPath} --strip-path-prefix ${workspacePrefix}/ ${sourcePath}`;
214212
runtimeArgs = runtimeArgs ? `${runtimeArgs} ${args}` : args;
215-
let preopens = [`--dir ${sourceDir}`];
213+
let preopens = [`--dir ${sourcesDir}`];
216214
if (opts.enableAot) {
217215
preopens.push(`--dir ${workspacePrefix}`);
218216
} else {
@@ -251,8 +249,8 @@ export async function componentize(
251249
'-w',
252250
'--init-func',
253251
'componentize.wizer',
254-
`-i ${input}`,
255-
`-o ${output}`,
252+
`-i ${inputWasmPath}`,
253+
`-o ${outputWasmPath}`,
256254
],
257255
{
258256
stdio: [null, stdout, 'pipe'],
@@ -272,8 +270,8 @@ export async function componentize(
272270
...preopens,
273271
`--wasm-bulk-memory=true`,
274272
'--inherit-env=true',
275-
`-o=${output}`,
276-
input,
273+
`-o=${outputWasmPath}`,
274+
inputWasmPath,
277275
],
278276
{
279277
stdio: [null, stdout, 'pipe'],
@@ -291,16 +289,16 @@ export async function componentize(
291289
if (debugBindings) {
292290
err += `\n\nBinary and sources available for debugging at ${tmpDir}\n`;
293291
} else {
294-
rmSync(tmpDir, { recursive: true });
292+
await rm(workDir, { recursive: true });
295293
}
296294
throw new Error(err);
297295
}
298296

297+
// Read the generated WASM back into memory
299298
const bin = await readFile(outputWasmPath);
300299

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
304302
const {
305303
exports: { check_init },
306304
getStderr,

0 commit comments

Comments
 (0)