Skip to content

Commit 1223b3a

Browse files
committed
build: Switch to esbuild instead of rollup for the client and banner
This reverts commit 872e710 (revert of the revert).
1 parent 7f2873f commit 1223b3a

File tree

5 files changed

+93
-42
lines changed

5 files changed

+93
-42
lines changed

banner.rollup.config.js

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

esbuild.js

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
const esbuild = require('esbuild');
2+
const fs = require('fs');
3+
4+
const defaultOptions = {
5+
bundle: true,
6+
platform: 'node',
7+
logLevel: 'info',
8+
};
9+
10+
/** @type esbuild.BuildOptions */
11+
const clientConfig = {
12+
...defaultOptions,
13+
entryPoints: ['dist/client/extension.js'],
14+
outfile: 'dist/npm/index.js',
15+
external: [
16+
'fs',
17+
'path',
18+
'vscode',
19+
'vscode-languageclient/node',
20+
'vscode-languageserver-protocol',
21+
'vscode-jsonrpc',
22+
],
23+
format: 'cjs',
24+
minify: true,
25+
};
26+
27+
/** @type esbuild.BuildOptions */
28+
const bannerConfig = {
29+
...defaultOptions,
30+
entryPoints: ['dist/banner/banner.js'],
31+
outfile: 'dist/banner/banner.esbuild.js',
32+
external: [
33+
'path',
34+
],
35+
format: 'cjs',
36+
};
37+
38+
/** @type esbuild.BuildOptions */
39+
const serverConfig = {
40+
...defaultOptions,
41+
entryPoints: ['dist/server/server.js'],
42+
outfile: 'dist/npm/server/index.js',
43+
external: [
44+
'fs',
45+
'path',
46+
'typescript/lib/tsserverlibrary',
47+
'vscode-languageserver',
48+
'vscode-uri',
49+
'vscode-jsonrpc',
50+
],
51+
// TODO(atscott): Figure out how to use the banner correctly.
52+
// iife format produces a `require("typescript/lib/tsserverlibrary");` line but it needs to use
53+
// the `define` in the banner to resolve tsserverlibrary.
54+
format: 'iife',
55+
};
56+
57+
async function build() {
58+
try {
59+
await esbuild.build(clientConfig);
60+
await esbuild.build(bannerConfig);
61+
} catch (e) {
62+
console.error(e);
63+
process.exit(1);
64+
}
65+
}
66+
67+
build();

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,7 @@
136136
],
137137
"main": "./dist/client/extension",
138138
"scripts": {
139-
"compile": "yarn compile:banner && tsc -b && rollup -c",
140-
"compile:banner": "tsc -p server/banner.tsconfig.json && rollup -c banner.rollup.config.js",
139+
"compile": "tsc -p server/banner.tsconfig.json && tsc -b && node esbuild.js && rollup -c",
141140
"compile:test": "tsc -b server/src/tests",
142141
"compile:integration": "tsc -b integration",
143142
"compile:syntaxes-test": "tsc -b syntaxes/test",
@@ -163,6 +162,7 @@
163162
"@types/jasmine": "3.6.3",
164163
"@types/node": "12.19.16",
165164
"clang-format": "1.5.0",
165+
"esbuild": "^0.9.0",
166166
"jasmine": "3.6.4",
167167
"prettier": "2.2.1",
168168
"rollup": "2.38.5",
@@ -178,4 +178,4 @@
178178
"type": "git",
179179
"url": "https://github.com/angular/vscode-ng-language-service"
180180
}
181-
}
181+
}

rollup.config.js

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,12 @@ import * as fs from 'fs';
22
import commonjs from 'rollup-plugin-commonjs';
33

44
module.exports = [
5-
{
6-
input: 'dist/client/extension.js',
7-
output: {
8-
file: 'dist/npm/index.js',
9-
format: 'cjs',
10-
exports: 'named',
11-
},
12-
external: [
13-
'path',
14-
'vscode',
15-
'vscode-languageclient',
16-
],
17-
plugins: [
18-
commonjs(),
19-
],
20-
},
215
{
226
input: 'dist/server/server.js',
237
output: {
248
file: 'dist/npm/server/index.js',
259
format: 'amd',
26-
banner: fs.readFileSync('dist/banner/banner.rollup.js', 'utf8'),
10+
banner: fs.readFileSync('dist/banner/banner.esbuild.js', 'utf8'),
2711
},
2812
external: [
2913
'fs',
@@ -41,4 +25,4 @@ module.exports = [
4125
}),
4226
],
4327
},
44-
];
28+
];

yarn.lock

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
integrity sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==
3535

3636
"@types/estree@*":
37-
version "0.0.45"
38-
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.45.tgz#e9387572998e5ecdac221950dab3e8c3b16af884"
39-
integrity sha512-jnqIUKDUqJbDIUxm0Uj7bnlMnRm1T/eZ9N+AVMqhPgzrba2GhGG5o/jCTwmdPK709nEZsGoMzXEDUjcXHa3W0g==
37+
version "0.0.46"
38+
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.46.tgz#0fb6bfbbeabd7a30880504993369c4bf1deab1fe"
39+
integrity sha512-laIjwTQaD+5DukBZaygQ79K1Z0jb1bPEMRrkXSLjtCcZm+abyp5YbrqpSLzD42FwWW6gK/aS4NYpJ804nG2brg==
4040

4141
4242
version "3.6.3"
@@ -331,6 +331,11 @@ es6-promisify@^5.0.0:
331331
dependencies:
332332
es6-promise "^4.0.3"
333333

334+
esbuild@^0.9.0:
335+
version "0.9.0"
336+
resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.9.0.tgz#b8320df85048ed1637c6b59ee52abba248936d3c"
337+
integrity sha512-IqYFO7ZKHf0y4uJpJfGqInmSRn8jMPMbyI1W0Y2PSjSjJcVP538tC8TleJAS4Y8QeqwajqBTwFKayWVzYlMIgg==
338+
334339
[email protected], escape-string-regexp@^1.0.5:
335340
version "1.0.5"
336341
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
@@ -364,9 +369,9 @@ fs.realpath@^1.0.0:
364369
integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8=
365370

366371
fsevents@~2.3.1:
367-
version "2.3.1"
368-
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.1.tgz#b209ab14c61012636c8863507edf7fb68cc54e9f"
369-
integrity sha512-YR47Eg4hChJGAB1O3yEAOkGO+rlzutoICGqGo9EZ4lKWokzZRSyIW1QmTzqjtw8MJdj9srP869CuWw/hyzSiBw==
372+
version "2.3.2"
373+
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a"
374+
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==
370375

371376
function-bind@^1.1.1:
372377
version "1.1.1"
@@ -477,7 +482,7 @@ inherits@2, inherits@^2.0.1, inherits@^2.0.3:
477482
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c"
478483
integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==
479484

480-
is-core-module@^2.1.0:
485+
is-core-module@^2.1.0, is-core-module@^2.2.0:
481486
version "2.2.0"
482487
resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.2.0.tgz#97037ef3d52224d85163f5597b2b63d9afed981a"
483488
integrity sha512-XRAfAdyyY5F5cOXn7hYQDqh2Xmii+DEfIcQGxK/uNwMHhIkPWO0g8msXcbzLe+MpGoR951MlqM/2iIlU4vKDdQ==
@@ -741,14 +746,22 @@ readable-stream@^3.1.1:
741746
string_decoder "^1.1.1"
742747
util-deprecate "^1.0.1"
743748

744-
resolve@^1.1.6, resolve@^1.11.0, resolve@^1.3.2:
749+
resolve@^1.1.6, resolve@^1.3.2:
745750
version "1.19.0"
746751
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.19.0.tgz#1af5bf630409734a067cae29318aac7fa29a267c"
747752
integrity sha512-rArEXAgsBG4UgRGcynxWIWKFvh/XZCcS8UJdHhwy91zwAvCZIbcs+vAbflgBnNjYMs/i/i+/Ux6IZhML1yPvxg==
748753
dependencies:
749754
is-core-module "^2.1.0"
750755
path-parse "^1.0.6"
751756

757+
resolve@^1.11.0:
758+
version "1.20.0"
759+
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.20.0.tgz#629a013fb3f70755d6f0b7935cc1c2c5378b1975"
760+
integrity sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==
761+
dependencies:
762+
is-core-module "^2.2.0"
763+
path-parse "^1.0.6"
764+
752765
753766
version "10.1.0"
754767
resolved "https://registry.yarnpkg.com/rollup-plugin-commonjs/-/rollup-plugin-commonjs-10.1.0.tgz#417af3b54503878e084d127adf4d1caf8beb86fb"

0 commit comments

Comments
 (0)