Skip to content

Commit 1c80e8e

Browse files
Fix Compiling latest VS Code Version 1.91 fails & other improvements (#38)
* enhanced build (from zorse) * bump up vscode-version to 1.81.1 * fix workbench compile errors (from zorse) * fetch product.json relative (so demo can be hosted in nested path) * fix build node version * bump up node and action version in publish * no patching * implemented feedback
1 parent 97ee15a commit 1c80e8e

File tree

4 files changed

+63
-18
lines changed

4 files changed

+63
-18
lines changed

.github/workflows/npm-publish.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ jobs:
1111
build:
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v2
15-
- uses: actions/setup-node@v1
14+
- uses: actions/checkout@v4
15+
- uses: actions/setup-node@v4
1616
with:
17-
node-version: 18
17+
node-version: 20
1818
registry-url: https://registry.npmjs.org/
1919
- name: Setup Build Environment
2020
run: |

build.js

Lines changed: 56 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,79 @@ const process = require("process");
22
const child_process = require("child_process");
33
const fs = require("fs");
44
const fse = require("fs-extra");
5+
const { version } = require("./package.json");
56

6-
const vscodeVersion = "1.84.2";
7+
const vscodeVersion = version.split("-")[0];
8+
9+
function error(msg) {
10+
console.info("\x1b[31merror %s\x1b[0m", msg)
11+
}
12+
function ok(msg) {
13+
console.info("\x1b[32m%s\x1b[0m", msg)
14+
}
15+
function note(msg) {
16+
console.info("\x1b[90m%s\x1b[0m", msg)
17+
}
18+
function exec(cmd, opts) {
19+
console.info("\x1b[36m%s\x1b[0m", cmd)
20+
return child_process.execSync(cmd, opts);
21+
}
22+
23+
const requiredTools = ["node", "yarn", "git", "python"];
24+
note(`required tools ${JSON.stringify(requiredTools)}`)
25+
for (const tool of requiredTools) {
26+
try {
27+
child_process.execSync(`${tool} --version`, { stdio: "ignore" });
28+
} catch (e) {
29+
error(`"${tool}" is not available.`);
30+
process.exit(1);
31+
}
32+
}
33+
ok("required tools installed")
34+
35+
const node_version_out = child_process.execSync(`node -v`);
36+
const node_version = node_version_out.toString().trim()
37+
if (node_version < "v20.0") {
38+
error(`Want node > 20. Got "${node_version}"`);
39+
process.exit(1);
40+
}
741

842
if (!fs.existsSync("vscode")) {
9-
child_process.execSync(`git clone --depth 1 https://github.com/microsoft/vscode.git -b ${vscodeVersion}`, {
43+
note("cloning vscode")
44+
exec(`git clone --depth 1 https://github.com/microsoft/vscode.git -b ${vscodeVersion}`, {
1045
stdio: "inherit",
1146
});
47+
} else {
48+
ok("vscode already installed")
49+
note("delete vscode folder to clone again")
1250
}
51+
52+
note("changing directory to vscode")
1353
process.chdir("vscode");
1454

1555
if (!fs.existsSync("node_modules")) {
16-
child_process.execSync("yarn", { stdio: "inherit" });
56+
exec("yarn", { stdio: "inherit" });
57+
} else {
58+
ok("node_modules exists. Skipping yarn")
1759
}
60+
1861
// Use simple workbench
19-
fs.copyFileSync(
20-
"../workbench.ts",
21-
"src/vs/code/browser/workbench/workbench.ts"
22-
);
62+
note("copying workbench file")
63+
fs.copyFileSync("../workbench.ts", "src/vs/code/browser/workbench/workbench.ts");
2364

2465
// Compile
25-
child_process.execSync("yarn gulp vscode-web-min", { stdio: "inherit" });
66+
note("starting compile")
67+
exec("yarn gulp vscode-web-min", { stdio: "inherit" });
68+
ok("compile completed")
2669

2770
// Extract compiled files
2871
if (fs.existsSync("../dist")) {
72+
note("cleaning ../dist")
2973
fs.rmdirSync("../dist", { recursive: true });
74+
} else {
75+
ok("../dist did not exist. No need to clean")
3076
}
77+
3178
fs.mkdirSync("../dist");
3279
fse.copySync("../vscode-web", "../dist");
33-
34-
80+
ok("copied ../vscode-web to ../dist")

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vscode-web",
3-
"version": "1.84.2",
3+
"version": "1.91.1",
44
"description": "Visual Studio Code for browser",
55
"files": ["dist"],
66
"scripts": {

workbench.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import {
22
create
33
} from "vs/workbench/workbench.web.main";
44
import { URI, UriComponents } from "vs/base/common/uri";
5-
import { IWorkbenchConstructionOptions } from "vs/workbench/browser/web.api";
6-
import { IWorkspace, IWorkspaceProvider } from "vs/workbench/services/host/browser/browserHostService";
5+
import { IWorkbenchConstructionOptions, IWorkspace, IWorkspaceProvider } from "vs/workbench/browser/web.api";
76
declare const window: any;
87

98
(async function () {
@@ -17,7 +16,7 @@ declare const window: any;
1716
if (window.product) {
1817
config = window.product;
1918
} else {
20-
const result = await fetch("/product.json");
19+
const result = await fetch("product.json");
2120
config = await result.json();
2221
}
2322

@@ -55,4 +54,4 @@ declare const window: any;
5554
|| document.body;
5655

5756
create(domElement, config);
58-
})();
57+
})();

0 commit comments

Comments
 (0)