Skip to content

Commit 74cf653

Browse files
harmony7Jake Champion
andauthored
Remove containsSyntaxErrors step from compile process (#848)
Co-authored-by: Jake Champion <[email protected]>
1 parent 38b558c commit 74cf653

File tree

3 files changed

+16
-32
lines changed

3 files changed

+16
-32
lines changed

integration-tests/cli/invalid.test.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ test('should return non-zero exit code on syntax errors', async function (t) {
1313
const { code, stdout, stderr } = await execute(process.execPath, cli);
1414
t.alike(stdout, []);
1515
t.alike(stderr, [
16-
'{{base}}/bin/index.js:4',
17-
'"hello";@',
18-
'^',
19-
'SyntaxError: Invalid or unexpected token'
16+
'✘ [ERROR] Expected identifier but found end of file',
17+
'bin/index.js:4:9:',
18+
'4 │ "hello";@',
19+
'╵ ^',
20+
'Error: Build failed with 1 error:',
21+
'bin/index.js:4:9: ERROR: Expected identifier but found end of file',
2022
]);
2123

2224
t.is(code, 1);

src/compileApplicationToWasm.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import wizer from "@bytecodealliance/wizer";
99
import { precompile } from "./precompile.js";
1010
import { enableTopLevelAwait } from "./enableTopLevelAwait.js";
1111
import { bundle } from "./bundle.js";
12-
import { containsSyntaxErrors } from "./containsSyntaxErrors.js";
1312

1413
async function getTmpDir () {
1514
return await mkdtemp(normalize(tmpdir() + sep));
@@ -88,13 +87,19 @@ export async function compileApplicationToWasm(
8887
process.exit(1);
8988
}
9089

91-
if (containsSyntaxErrors(input)) {
90+
let wizerInput, cleanup = () => {};
91+
92+
let contents;
93+
try {
94+
contents = await bundle(input, enableExperimentalTopLevelAwait);
95+
} catch (error) {
96+
console.error(
97+
`Error:`,
98+
error.message
99+
);
92100
process.exit(1);
93101
}
94102

95-
let wizerInput, cleanup = () => {};
96-
97-
let contents = await bundle(input, enableExperimentalTopLevelAwait);
98103
wizerInput = precompile(
99104
contents.outputFiles[0].text,
100105
undefined,

src/containsSyntaxErrors.js

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)