Skip to content

Commit 59e754e

Browse files
committed
Avoid unhandled errors in build streams
The .pipe() method on Node.js streams have a gotcha in that they do not propagate errors downstream. In this case this meant that if compilation failed with an error, it would not be visible to Gulp because Gulp only sees the stream that writes to a file, not the intermediate 'esbuild' stream that generated the error. This changes a few uses of .pipe() to the more modern stream.pipeline(), which propagates errors correctly.
1 parent 6e59d40 commit 59e754e

File tree

3 files changed

+42
-37
lines changed

3 files changed

+42
-37
lines changed

extensions/ql-vscode/gulpfile.ts/textmate.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import type {
99
Pattern,
1010
TextmateGrammar,
1111
} from "./textmate-grammar";
12+
import { pipeline } from "stream/promises";
1213

1314
/**
1415
* Replaces all rule references with the match pattern of the referenced rule.
@@ -276,7 +277,9 @@ export function transpileTextMateGrammar() {
276277
}
277278

278279
export function compileTextMateGrammar() {
279-
return src("syntaxes/*.tmLanguage.yml")
280-
.pipe(transpileTextMateGrammar())
281-
.pipe(dest("out/syntaxes"));
280+
return pipeline(
281+
src("syntaxes/*.tmLanguage.yml"),
282+
transpileTextMateGrammar(),
283+
dest("out/syntaxes"),
284+
);
282285
}

extensions/ql-vscode/gulpfile.ts/typescript.ts

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import esbuild from "gulp-esbuild";
44
import type { reporter } from "gulp-typescript";
55
import { createProject } from "gulp-typescript";
66
import del from "del";
7+
import { pipeline } from "stream/promises";
78

89
export function goodReporter(): reporter.Reporter {
910
return {
@@ -37,23 +38,23 @@ export function cleanOutput() {
3738
}
3839

3940
export function compileEsbuild() {
40-
return src("./src/extension.ts")
41-
.pipe(
42-
esbuild({
43-
outfile: "extension.js",
44-
bundle: true,
45-
external: ["vscode", "fsevents"],
46-
format: "cjs",
47-
platform: "node",
48-
target: "es2020",
49-
sourcemap: "linked",
50-
sourceRoot: "..",
51-
loader: {
52-
".node": "copy",
53-
},
54-
}),
55-
)
56-
.pipe(dest("out"));
41+
return pipeline(
42+
src("./src/extension.ts"),
43+
esbuild({
44+
outfile: "extension.js",
45+
bundle: true,
46+
external: ["vscode", "fsevents"],
47+
format: "cjs",
48+
platform: "node",
49+
target: "es2020",
50+
sourcemap: "linked",
51+
sourceRoot: "..",
52+
loader: {
53+
".node": "copy",
54+
},
55+
}),
56+
dest("out"),
57+
);
5758
}
5859

5960
export function watchEsbuild() {

extensions/ql-vscode/gulpfile.ts/view.ts

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,29 @@ import esbuild from "gulp-esbuild";
33
import { createProject } from "gulp-typescript";
44
import { goodReporter } from "./typescript";
55

6+
import { pipeline } from "stream/promises";
67
import chromiumVersion from "./chromium-version.json";
78

89
const tsProject = createProject("src/view/tsconfig.json");
910

1011
export function compileViewEsbuild() {
11-
return src("./src/view/webview.tsx")
12-
.pipe(
13-
esbuild({
14-
outfile: "webview.js",
15-
bundle: true,
16-
format: "iife",
17-
platform: "browser",
18-
target: `chrome${chromiumVersion.chromiumVersion}`,
19-
jsx: "automatic",
20-
sourcemap: "linked",
21-
sourceRoot: "..",
22-
loader: {
23-
".ttf": "file",
24-
},
25-
}),
26-
)
27-
.pipe(dest("out"));
12+
return pipeline(
13+
src("./src/view/webview.tsx"),
14+
esbuild({
15+
outfile: "webview.js",
16+
bundle: true,
17+
format: "iife",
18+
platform: "browser",
19+
target: `chrome${chromiumVersion.chromiumVersion}`,
20+
jsx: "automatic",
21+
sourcemap: "linked",
22+
sourceRoot: "..",
23+
loader: {
24+
".ttf": "file",
25+
},
26+
}),
27+
dest("out"),
28+
);
2829
}
2930

3031
export function watchViewEsbuild() {

0 commit comments

Comments
 (0)