Skip to content

Commit 6b75c6c

Browse files
committed
Use esbuild for building VSCode extensions
Signed-off-by: BoykoAlex <alex.boyko@broadcom.com>
1 parent 637aacc commit 6b75c6c

File tree

20 files changed

+277
-239
lines changed

20 files changed

+277
-239
lines changed

vscode-extensions/vscode-bosh/.vscode/tasks.json

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,14 @@
66
"script": "watch",
77
"problemMatcher": {
88
"owner": "typescript",
9-
"pattern":[
10-
{
11-
"regexp": "\\[tsl\\] ERROR",
12-
"file": 1,
13-
"location": 2,
14-
"message": 3
15-
}
16-
],
9+
"pattern": {
10+
"regexp": "\\[ERROR\\] (.+)",
11+
"message": 1
12+
},
1713
"background": {
1814
"activeOnStart": true,
19-
"beginsPattern": "\\w+",
20-
"endsPattern": "webpack .* compiled"
15+
"beginsPattern": "\\[watch\\] build started",
16+
"endsPattern": "\\[watch\\] build finished"
2117
}
2218
},
2319
"isBackground": true,

vscode-extensions/vscode-bosh/.vscodeignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ build.sh
2323

2424
# Build tooling
2525
node_modules
26-
webpack.config.js
26+
esbuild.js
2727

2828
# Compiler output (old tsc output)
2929
out/**
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
const esbuild = require('esbuild');
2+
3+
const production = process.argv.includes('--production');
4+
const watch = process.argv.includes('--watch');
5+
6+
async function main() {
7+
const ctx = await esbuild.context({
8+
entryPoints: ['lib/Main.ts'],
9+
bundle: true,
10+
format: 'cjs',
11+
minify: production,
12+
sourcemap: !production,
13+
sourcesContent: false,
14+
platform: 'node',
15+
outfile: 'dist/extension.js',
16+
external: ['vscode'],
17+
logLevel: 'silent',
18+
plugins: [
19+
esbuildProblemMatcherPlugin
20+
]
21+
});
22+
if (watch) {
23+
await ctx.watch();
24+
} else {
25+
await ctx.rebuild();
26+
await ctx.dispose();
27+
}
28+
}
29+
30+
/**
31+
* This plugin hooks into the build process to print errors in a format
32+
* that the VS Code problem matcher (`$esbuild-watch`) can detect.
33+
*/
34+
const esbuildProblemMatcherPlugin = {
35+
name: 'esbuild-problem-matcher',
36+
setup(build) {
37+
build.onStart(() => {
38+
console.log('[watch] build started');
39+
});
40+
build.onEnd(result => {
41+
result.errors.forEach(({ text, location }) => {
42+
console.error(`✘ [ERROR] ${text}`);
43+
if (location) {
44+
console.error(` ${location.file}:${location.line}:${location.column}:`);
45+
}
46+
});
47+
console.log('[watch] build finished');
48+
});
49+
}
50+
};
51+
52+
main().catch(e => {
53+
console.error(e);
54+
process.exit(1);
55+
});

vscode-extensions/vscode-bosh/package.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,11 @@
134134
},
135135
"main": "./dist/extension",
136136
"scripts": {
137-
"vscode:prepublish": "npm run package",
138-
"package": "webpack --mode production --devtool hidden-source-map",
139-
"compile": "webpack --mode development",
140-
"watch": "webpack --mode development --watch",
137+
"vscode:prepublish": "npm run check-types && npm run package",
138+
"package": "node esbuild.js --production",
139+
"check-types": "tsc --noEmit",
140+
"compile": "node esbuild.js",
141+
"watch": "node esbuild.js --watch",
141142
"clean": "rm -fr node_modules out dist *.vsix package-lock.json",
142143
"vsce-package": "vsce package",
143144
"vsce-pre-release-package": "vsce package --pre-release"
@@ -150,9 +151,7 @@
150151
"@types/node": "^18.8.0",
151152
"@types/vscode": "1.75.0",
152153
"@vscode/vsce": "^2.22.0",
153-
"ts-loader": "^9.5.1",
154-
"typescript": "^4.8.0",
155-
"webpack": "^5.91.0",
156-
"webpack-cli": "^5.1.4"
154+
"esbuild": "^0.25.0",
155+
"typescript": "^4.8.0"
157156
}
158157
}

vscode-extensions/vscode-bosh/webpack.config.js

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

vscode-extensions/vscode-concourse/.vscode/tasks.json

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,14 @@
66
"script": "watch",
77
"problemMatcher": {
88
"owner": "typescript",
9-
"pattern":[
10-
{
11-
"regexp": "\\[tsl\\] ERROR",
12-
"file": 1,
13-
"location": 2,
14-
"message": 3
15-
}
16-
],
9+
"pattern": {
10+
"regexp": "\\[ERROR\\] (.+)",
11+
"message": 1
12+
},
1713
"background": {
1814
"activeOnStart": true,
19-
"beginsPattern": "\\w+",
20-
"endsPattern": "webpack .* compiled"
15+
"beginsPattern": "\\[watch\\] build started",
16+
"endsPattern": "\\[watch\\] build finished"
2117
}
2218
},
2319
"isBackground": true,

vscode-extensions/vscode-concourse/.vscodeignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ build.sh
2323

2424
# Build tooling
2525
node_modules
26-
webpack.config.js
26+
esbuild.js
2727

2828
# Compiler output (old tsc output)
2929
out/**
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
const esbuild = require('esbuild');
2+
3+
const production = process.argv.includes('--production');
4+
const watch = process.argv.includes('--watch');
5+
6+
async function main() {
7+
const ctx = await esbuild.context({
8+
entryPoints: ['lib/Main.ts'],
9+
bundle: true,
10+
format: 'cjs',
11+
minify: production,
12+
sourcemap: !production,
13+
sourcesContent: false,
14+
platform: 'node',
15+
outfile: 'dist/extension.js',
16+
external: ['vscode'],
17+
logLevel: 'silent',
18+
plugins: [
19+
esbuildProblemMatcherPlugin
20+
]
21+
});
22+
if (watch) {
23+
await ctx.watch();
24+
} else {
25+
await ctx.rebuild();
26+
await ctx.dispose();
27+
}
28+
}
29+
30+
/**
31+
* This plugin hooks into the build process to print errors in a format
32+
* that the VS Code problem matcher (`$esbuild-watch`) can detect.
33+
*/
34+
const esbuildProblemMatcherPlugin = {
35+
name: 'esbuild-problem-matcher',
36+
setup(build) {
37+
build.onStart(() => {
38+
console.log('[watch] build started');
39+
});
40+
build.onEnd(result => {
41+
result.errors.forEach(({ text, location }) => {
42+
console.error(`✘ [ERROR] ${text}`);
43+
if (location) {
44+
console.error(` ${location.file}:${location.line}:${location.column}:`);
45+
}
46+
});
47+
console.log('[watch] build finished');
48+
});
49+
}
50+
};
51+
52+
main().catch(e => {
53+
console.error(e);
54+
process.exit(1);
55+
});

vscode-extensions/vscode-concourse/package.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,11 @@
134134
},
135135
"main": "./dist/extension",
136136
"scripts": {
137-
"vscode:prepublish": "npm run package",
138-
"package": "webpack --mode production --devtool hidden-source-map",
139-
"compile": "webpack --mode development",
140-
"watch": "webpack --mode development --watch",
137+
"vscode:prepublish": "npm run check-types && npm run package",
138+
"package": "node esbuild.js --production",
139+
"check-types": "tsc --noEmit",
140+
"compile": "node esbuild.js",
141+
"watch": "node esbuild.js --watch",
141142
"clean": "rm -fr node_modules out dist *.vsix package-lock.json",
142143
"vsce-package": "vsce package",
143144
"vsce-pre-release-package": "vsce package --pre-release"
@@ -150,9 +151,7 @@
150151
"@types/node": "^18.8.0",
151152
"@types/vscode": "1.75.0",
152153
"@vscode/vsce": "^2.22.0",
153-
"ts-loader": "^9.5.1",
154-
"typescript": "^4.8.0",
155-
"webpack": "^5.91.0",
156-
"webpack-cli": "^5.1.4"
154+
"esbuild": "^0.25.0",
155+
"typescript": "^4.8.0"
157156
}
158157
}

vscode-extensions/vscode-concourse/webpack.config.js

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

0 commit comments

Comments
 (0)