Skip to content

Commit 870874d

Browse files
authored
Merge pull request #3174 from github/koesie10/view-esbuild
Switch view to ESBuild and JSX runtime
2 parents 856f97f + 27a326a commit 870874d

File tree

194 files changed

+145
-599
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

194 files changed

+145
-599
lines changed
85.5 KB
Loading
9.99 KB
Loading

docs/images/electron-version.png

10.2 KB
Loading

docs/node-version.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ We should make sure the CodeQL for VS Code extension works with the Node.js vers
77

88
## Checking the version of Node.js supplied by VS Code
99

10-
You can find this info by seleting "About Visual Studio Code" from the top menu.
10+
You can find this info by selecting "About Visual Studio Code" from the top menu.
1111

1212
![about-vscode](images/about-vscode.png)
1313

docs/vscode-version.md

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,49 @@ Also consider what percentage of our users are using each VS Code version. This
2424

2525
## How to update the VS Code version
2626

27-
To provide a good experience to users, it is recommented to update the `MIN_VERSION` in `extension.ts` first and release, and then update the `vscode` version in `package.json` and release again. By stagging this update across two releases it gives users on older VS Code versions a chance to upgrade before it silently refuses to upgrade them.
27+
To provide a good experience to users, it is recommented to update the `MIN_VERSION` in `extension.ts` first and release, and then update the `vscode` version in `package.json` and release again.
28+
By staggering this update across two releases it gives users on older VS Code versions a chance to upgrade before it silently refuses to upgrade them.
29+
30+
When updating the minimum version in `package.json`, you should also follow the additional steps listed below.
31+
32+
### Updating the Chromium target version
33+
34+
For the webview code, we use [esbuild](https://esbuild.github.io/) to bundle the code. This requires a target version of Chromium to be specified.
35+
This version should be the same as the version of Chromium that is bundled with the new minimum VS Code version. There are two
36+
methods to find this version.
37+
38+
#### Using the About Visual Studio Code dialog
39+
40+
Download the new minimum VS Code version from [the previous release versions](https://code.visualstudio.com/docs/supporting/faq#_previous-release-versions). Then,
41+
select "About Visual Studio Code" from the top menu. This will show the version of Chromium that is bundled with that version of VS Code.
42+
43+
![Chromium version in the About Visual Studio Code dialog](images/about-vscode-chromium.png)
44+
45+
In this case, the `target` would be `chrome114`.
46+
47+
#### Using the VS Code source code
48+
49+
You can find the version of Electron that VS Code uses by looking at its `package.json` file for a specific version
50+
(for example [the `package.json` for `1.82.0`](https://github.com/microsoft/vscode/blob/1.82.0/package.json#L153)).
51+
52+
![Electron version in the `package.json` file](images/electron-version.png)
53+
54+
Then, you can find the version of Chromium that is bundled with that version of Electron by looking at the
55+
Chromium version that is shown for that Electron version on [the Electron releases site](https://releases.electronjs.org/releases/stable)
56+
(for example [the `25.8.0` release](https://releases.electronjs.org/release/v25.8.0)):
57+
58+
![Chromium version in the Electron releases site](images/electron-chromium-version.png)
59+
60+
In this case, the `target` would be `chrome114`.
61+
62+
#### Troubleshooting
63+
64+
In case there's an error when specifying a version of Chromium, you may need to update the version of `caniuse-lite`
65+
in `package.json` to a newer version. You should be able to do so by running:
66+
67+
```shell
68+
npx update-browserslist-db@latest
69+
```
2870

2971
## VS Code version used in tests
3072

extensions/ql-vscode/.eslintrc.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ const baseConfig = {
2121
},
2222
extends: [
2323
"eslint:recommended",
24-
"plugin:github/react",
2524
"plugin:github/recommended",
2625
"plugin:github/typescript",
2726
"plugin:jest-dom/recommended",
@@ -94,8 +93,10 @@ module.exports = {
9493
extends: [
9594
...baseConfig.extends,
9695
"plugin:react/recommended",
96+
"plugin:react/jsx-runtime",
9797
"plugin:react-hooks/recommended",
9898
"plugin:storybook/recommended",
99+
"plugin:github/react",
99100
],
100101
rules: {
101102
...baseConfig.rules,
@@ -114,7 +115,9 @@ module.exports = {
114115
extends: [
115116
...baseConfig.extends,
116117
"plugin:react/recommended",
118+
"plugin:react/jsx-runtime",
117119
"plugin:react-hooks/recommended",
120+
"plugin:github/react",
118121
],
119122
rules: {
120123
...baseConfig.rules,

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

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,14 @@ import {
88
copyWasmFiles,
99
} from "./typescript";
1010
import { compileTextMateGrammar } from "./textmate";
11-
import { compileView, watchView } from "./webpack";
1211
import { packageExtension } from "./package";
1312
import { injectAppInsightsKey } from "./appInsights";
13+
import {
14+
checkViewTypeScript,
15+
compileViewEsbuild,
16+
watchViewCheckTypeScript,
17+
watchViewEsbuild,
18+
} from "./view";
1419

1520
export const buildWithoutPackage = series(
1621
cleanOutput,
@@ -19,23 +24,33 @@ export const buildWithoutPackage = series(
1924
copyWasmFiles,
2025
checkTypeScript,
2126
compileTextMateGrammar,
22-
compileView,
27+
compileViewEsbuild,
28+
checkViewTypeScript,
2329
),
2430
);
2531

26-
export const watch = parallel(watchEsbuild, watchCheckTypeScript, watchView);
32+
export const watch = parallel(
33+
// Always build first, so that we don't have to run build manually
34+
compileEsbuild,
35+
compileViewEsbuild,
36+
watchEsbuild,
37+
watchCheckTypeScript,
38+
watchViewEsbuild,
39+
watchViewCheckTypeScript,
40+
);
2741

2842
export {
2943
cleanOutput,
3044
compileTextMateGrammar,
3145
watchEsbuild,
3246
watchCheckTypeScript,
33-
watchView,
47+
watchViewEsbuild,
3448
compileEsbuild,
3549
copyWasmFiles,
3650
checkTypeScript,
3751
injectAppInsightsKey,
38-
compileView,
52+
compileViewEsbuild,
53+
checkViewTypeScript,
3954
};
4055
export default series(
4156
buildWithoutPackage,

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import esbuild from "gulp-esbuild";
44
import { createProject, reporter } from "gulp-typescript";
55
import del from "del";
66

7-
function goodReporter(): reporter.Reporter {
7+
export function goodReporter(): reporter.Reporter {
88
return {
99
error: (error, typescript) => {
1010
if (error.tsFile) {
@@ -56,7 +56,7 @@ export function compileEsbuild() {
5656
}
5757

5858
export function watchEsbuild() {
59-
watch("src/**/*.ts", compileEsbuild);
59+
watch(["src/**/*.ts", "!src/view/**/*.ts"], compileEsbuild);
6060
}
6161

6262
export function checkTypeScript() {
@@ -66,7 +66,7 @@ export function checkTypeScript() {
6666
}
6767

6868
export function watchCheckTypeScript() {
69-
watch("src/**/*.ts", checkTypeScript);
69+
watch(["src/**/*.ts", "!src/view/**/*.ts"], checkTypeScript);
7070
}
7171

7272
export function copyWasmFiles() {
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { dest, src, watch } from "gulp";
2+
import esbuild from "gulp-esbuild";
3+
import { createProject } from "gulp-typescript";
4+
import { goodReporter } from "./typescript";
5+
6+
const tsProject = createProject("src/view/tsconfig.json");
7+
8+
export function compileViewEsbuild() {
9+
return src("./src/view/webview.tsx")
10+
.pipe(
11+
esbuild({
12+
outfile: "webview.js",
13+
bundle: true,
14+
format: "iife",
15+
platform: "browser",
16+
target: "chrome114", // Electron 25, VS Code 1.85
17+
jsx: "automatic",
18+
sourcemap: "linked",
19+
sourceRoot: "..",
20+
loader: {
21+
".ttf": "file",
22+
},
23+
}),
24+
)
25+
.pipe(dest("out"));
26+
}
27+
28+
export function watchViewEsbuild() {
29+
watch(["src/view/**/*.{ts,tsx}"], compileViewEsbuild);
30+
}
31+
32+
export function checkViewTypeScript() {
33+
// This doesn't actually output the TypeScript files, it just
34+
// runs the TypeScript compiler and reports any errors.
35+
return tsProject.src().pipe(tsProject(goodReporter()));
36+
}
37+
38+
export function watchViewCheckTypeScript() {
39+
watch(["src/view/**/*.{ts,tsx}"], checkViewTypeScript);
40+
}

extensions/ql-vscode/gulpfile.ts/webpack.config.ts

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

0 commit comments

Comments
 (0)