Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,19 @@
"esbuild": "^0.28.1",
"magic-string": "^0.30.12",
"picomatch": "^4.0.4",
"proper-lockfile": "^4.1.2",
"regexpu-core": "^6.4.0"
},
"devDependencies": {
"@eslint/js": "^9.39.1",
"@jakechampion/cli-testing-library": "^1.0.0",
"npm": "^11.14.1",
"@types/node": "^24.10.1",
"@types/picomatch": "^4.0.2",
"@types/proper-lockfile": "^4.1.4",
"brittle": "^3.5.2",
"eslint": "^9.39.1",
"get-bin-path": "^11.0.0",
"npm": "^11.14.1",
"prettier": "^3.3.3",
"remark-parse": "^11.0.0",
"remark-stringify": "^11.0.0",
Expand Down
6 changes: 3 additions & 3 deletions src/compileApplicationToWasm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import {
} from 'node:child_process';
import { mkdir, readFile, mkdtemp } from 'node:fs/promises';
import { rmSync } from 'node:fs';
import weval from '@bytecodealliance/weval';
import wasmtime from '@fastly/wasmtime';

import { isDirectory, isFile } from './files.js';
import { getWevalPath } from './getWevalPath.js';
import { CompilerContext } from './compilerPipeline.js';
import { bundleStep } from './compiler-steps/bundle.js';
import { precompileRegexesStep } from './compiler-steps/precompileRegexes.js';
Expand Down Expand Up @@ -212,7 +212,7 @@ export async function compileApplicationToWasm(
try {
if (!doBundle) {
if (!disableAOT) {
const wevalPath = wevalBin ?? (await weval());
const wevalPath = wevalBin ?? (await getWevalPath());

const wevalProcess = spawnSync(
`"${wevalPath}"`,
Expand Down Expand Up @@ -256,7 +256,7 @@ export async function compileApplicationToWasm(
} else {
spawnOpts.input = `${maybeWindowsPath(input)}${moduleMode ? '' : ' --legacy-script'}`;
if (!disableAOT) {
const wevalPath = wevalBin ?? (await weval());
const wevalPath = wevalBin ?? (await getWevalPath());

const wevalProcess = spawnSync(
`"${wevalPath}"`,
Expand Down
22 changes: 22 additions & 0 deletions src/getWevalPath.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { createRequire } from 'node:module';
import weval from '@bytecodealliance/weval';
import lockfile from 'proper-lockfile';

const wevalModulePath = createRequire(import.meta.url).resolve(
'@bytecodealliance/weval',
);

export async function getWevalPath(
install: () => Promise<string> = weval,
installationPath: string = wevalModulePath,
): Promise<string> {
const release = await lockfile.lock(installationPath, {
retries: { retries: 120, minTimeout: 1000, maxTimeout: 1000 },
});

try {
return await install();
} finally {
await release();
}
}
Loading