Skip to content

Commit 4ac5741

Browse files
committed
Prettier
1 parent 7360f3f commit 4ac5741

File tree

6 files changed

+74
-47
lines changed

6 files changed

+74
-47
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
"build:weval": "./runtime/fastly/build-release-weval.sh",
4141
"build:debug:info": "./runtime/fastly/build-debug.sh --keep-debug-info",
4242
"format-changelog": "node ci/format-changelog.js CHANGELOG.md",
43-
"format": "prettier --write *.js src/*.js integration-tests types test-d",
44-
"format:check": "prettier --check *.js src/*.js integration-tests"
43+
"format": "prettier --write 'src/**/*.ts' integration-tests types test-d",
44+
"format:check": "prettier --check 'src/**/*.ts' integration-tests"
4545
},
4646
"dependencies": {
4747
"@bytecodealliance/jco": "^1.7.0",

src/addSdkMetadataField.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ export async function addSdkMetadataField(wasmPath: string, usingAOT: boolean) {
99
encoding: 'utf-8',
1010
});
1111

12-
const { name, version } = JSON.parse(packageJson) as { name: string, version: string, };
12+
const { name, version } = JSON.parse(packageJson) as {
13+
name: string;
14+
version: string;
15+
};
1316

1417
let sdkName: string;
1518
if (usingAOT) {

src/compileApplicationToWasm.ts

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { dirname, resolve, sep, normalize } from 'node:path';
22
import { tmpdir, freemem } from 'node:os';
3-
import { spawnSync, type SpawnSyncOptionsWithStringEncoding } from 'node:child_process';
3+
import {
4+
spawnSync,
5+
type SpawnSyncOptionsWithStringEncoding,
6+
} from 'node:child_process';
47
import {
58
mkdir,
69
readFile,
@@ -29,23 +32,24 @@ async function getTmpDir() {
2932
}
3033

3134
export type CompileApplicationToWasmParams = {
32-
input: string,
33-
output: string,
34-
wasmEngine: string,
35-
enableHttpCache: boolean,
36-
enableExperimentalHighResolutionTimeMethods: boolean,
37-
enableAOT: boolean,
38-
aotCache: string,
39-
enableStackTraces: boolean,
40-
excludeSources: boolean,
41-
debugIntermediateFilesDir: string | undefined,
42-
moduleMode: boolean,
43-
doBundle: boolean,
44-
env: Record<string, string>,
35+
input: string;
36+
output: string;
37+
wasmEngine: string;
38+
enableHttpCache: boolean;
39+
enableExperimentalHighResolutionTimeMethods: boolean;
40+
enableAOT: boolean;
41+
aotCache: string;
42+
enableStackTraces: boolean;
43+
excludeSources: boolean;
44+
debugIntermediateFilesDir: string | undefined;
45+
moduleMode: boolean;
46+
doBundle: boolean;
47+
env: Record<string, string>;
4548
};
4649

47-
export async function compileApplicationToWasm(params: CompileApplicationToWasmParams) {
48-
50+
export async function compileApplicationToWasm(
51+
params: CompileApplicationToWasmParams,
52+
) {
4953
const {
5054
output,
5155
wasmEngine,
@@ -80,7 +84,8 @@ export async function compileApplicationToWasm(params: CompileApplicationToWasmP
8084
try {
8185
await readFile(input, { encoding: 'utf-8' });
8286
} catch (maybeError: unknown) {
83-
const error = maybeError instanceof Error ? maybeError : new Error(String(maybeError));
87+
const error =
88+
maybeError instanceof Error ? maybeError : new Error(String(maybeError));
8489
console.error(
8590
`Error: Failed to open the \`input\` (${input})`,
8691
error.message,
@@ -138,7 +143,10 @@ export async function compileApplicationToWasm(params: CompileApplicationToWasmP
138143
recursive: true,
139144
});
140145
} catch (maybeError: unknown) {
141-
const error = maybeError instanceof Error ? maybeError : new Error(String(maybeError));
146+
const error =
147+
maybeError instanceof Error
148+
? maybeError
149+
: new Error(String(maybeError));
142150
console.error(
143151
`Error: Failed to create the \`debug-intermediate-files\` (${debugIntermediateFilesDir}) directory`,
144152
error.message,
@@ -164,7 +172,10 @@ export async function compileApplicationToWasm(params: CompileApplicationToWasmP
164172
enableStackTraces,
165173
});
166174
} catch (maybeError: unknown) {
167-
const error = maybeError instanceof Error ? maybeError : new Error(String(maybeError));
175+
const error =
176+
maybeError instanceof Error
177+
? maybeError
178+
: new Error(String(maybeError));
168179
console.error(`Error:`, error.message);
169180
process.exit(1);
170181
}
@@ -215,7 +226,10 @@ export async function compileApplicationToWasm(params: CompileApplicationToWasmP
215226
if (enableStackTraces) {
216227
// Compose source maps
217228
const replaceSourceMapToken = '__FINAL_SOURCE_MAP__';
218-
let excludePatterns: ExcludePattern[] = ['forbid-entry:/**', 'node_modules/**'];
229+
let excludePatterns: ExcludePattern[] = [
230+
'forbid-entry:/**',
231+
'node_modules/**',
232+
];
219233
if (excludeSources) {
220234
excludePatterns = [() => true];
221235
}
@@ -274,7 +288,9 @@ export async function compileApplicationToWasm(params: CompileApplicationToWasmP
274288
ENABLE_EXPERIMENTAL_HIGH_RESOLUTION_TIME_METHODS:
275289
enableExperimentalHighResolutionTimeMethods ? '1' : '0',
276290
ENABLE_EXPERIMENTAL_HTTP_CACHE: enableHttpCache ? '1' : '0',
277-
RUST_MIN_STACK: String(Math.max(8 * 1024 * 1024, Math.floor(freemem() * 0.1))),
291+
RUST_MIN_STACK: String(
292+
Math.max(8 * 1024 * 1024, Math.floor(freemem() * 0.1)),
293+
),
278294
},
279295
} satisfies SpawnSyncOptionsWithStringEncoding;
280296

@@ -364,7 +380,8 @@ export async function compileApplicationToWasm(params: CompileApplicationToWasmP
364380
}
365381
}
366382
} catch (maybeError: unknown) {
367-
const error = maybeError instanceof Error ? maybeError : new Error(String(maybeError));
383+
const error =
384+
maybeError instanceof Error ? maybeError : new Error(String(maybeError));
368385
throw new Error(
369386
`Error: Failed to compile JavaScript to Wasm:\n${error.message}`,
370387
);

src/composeSourcemaps.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,24 @@ import picomatch from 'picomatch';
1010
export type ExcludePattern = string | ((file: string) => boolean);
1111

1212
export type SourceMapInfo = {
13-
f: string, // Filename
14-
s: string, // Sourcemap filename
13+
f: string; // Filename
14+
s: string; // Sourcemap filename
1515
};
1616

1717
async function readSourcemap(e: SourceMapInfo) {
1818
const sourceMapJson = await readFile(e.s, { encoding: 'utf-8' });
1919
return JSON.parse(sourceMapJson) as SourceMapInput;
2020
}
2121

22-
export async function composeSourcemaps(sourceMaps: SourceMapInfo[], excludePatterns: ExcludePattern[] = []) {
22+
export async function composeSourcemaps(
23+
sourceMaps: SourceMapInfo[],
24+
excludePatterns: ExcludePattern[] = [],
25+
) {
2326
const topSourceMap = sourceMaps.pop();
2427
if (topSourceMap == null) {
25-
throw new Error('Unexpected: composeSourcemaps received empty sourceMaps array.');
28+
throw new Error(
29+
'Unexpected: composeSourcemaps received empty sourceMaps array.',
30+
);
2631
}
2732

2833
const top = new TraceMap(await readSourcemap(topSourceMap));

src/parseInputs.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@ import { tooManyEngines, unknownArgument } from './printHelp.js';
44
import { EnvParser } from './env.js';
55

66
export type ParsedInputs =
7-
| 'help'
8-
| 'version'
9-
| {
10-
enableAOT: boolean,
11-
aotCache: string,
12-
enableHttpCache: boolean,
13-
enableExperimentalHighResolutionTimeMethods: boolean,
14-
moduleMode: boolean,
15-
bundle: boolean,
16-
enableStackTraces: boolean,
17-
excludeSources: boolean,
18-
debugIntermediateFilesDir: string | undefined,
19-
wasmEngine: string,
20-
input: string,
21-
output: string,
22-
env: Record<string, string>,
23-
};
7+
| 'help'
8+
| 'version'
9+
| {
10+
enableAOT: boolean;
11+
aotCache: string;
12+
enableHttpCache: boolean;
13+
enableExperimentalHighResolutionTimeMethods: boolean;
14+
moduleMode: boolean;
15+
bundle: boolean;
16+
enableStackTraces: boolean;
17+
excludeSources: boolean;
18+
debugIntermediateFilesDir: string | undefined;
19+
wasmEngine: string;
20+
input: string;
21+
output: string;
22+
env: Record<string, string>;
23+
};
2424

2525
export async function parseInputs(cliInputs: string[]): Promise<ParsedInputs> {
2626
const __dirname = dirname(fileURLToPath(import.meta.url));

src/swallowTopLevelExportsPlugin.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ export type SwallowTopLevelExportsPluginParams = {
55
entry?: string;
66
};
77

8-
export function swallowTopLevelExportsPlugin(opts?: SwallowTopLevelExportsPluginParams) {
8+
export function swallowTopLevelExportsPlugin(
9+
opts?: SwallowTopLevelExportsPluginParams,
10+
) {
911
const { entry } = opts ?? {};
1012

1113
const name = 'swallow-top-level-exports';

0 commit comments

Comments
 (0)