diff --git a/ci/build/build-release.sh b/ci/build/build-release.sh index 8b33af795..044603419 100755 --- a/ci/build/build-release.sh +++ b/ci/build/build-release.sh @@ -91,17 +91,17 @@ bundle_vscode() { rsync "${rsync_opts[@]}" ./lib/vscode-reh-web-*/ "$VSCODE_OUT_PATH" - # Use the package.json for the web/remote server. It does not have the right - # version though so pull that from the main package.json. - jq --slurp '.[0] * {version: .[1].version}' \ + # Merge the package.json for the web/remote server so we can include + # dependencies, since we want to ship this via NPM. + jq --slurp '.[0] * .[1]' \ "$VSCODE_SRC_PATH/remote/package.json" \ - "$VSCODE_SRC_PATH/package.json" > "$VSCODE_OUT_PATH/package.json" - - mv "$VSCODE_SRC_PATH/remote/npm-shrinkwrap.json" "$VSCODE_OUT_PATH/npm-shrinkwrap.json" + "$VSCODE_OUT_PATH/package.json" > "$VSCODE_OUT_PATH/package.json.merged" + mv "$VSCODE_OUT_PATH/package.json.merged" "$VSCODE_OUT_PATH/package.json" + cp "$VSCODE_SRC_PATH/remote/npm-shrinkwrap.json" "$VSCODE_OUT_PATH/npm-shrinkwrap.json" # Include global extension dependencies as well. rsync "$VSCODE_SRC_PATH/extensions/package.json" "$VSCODE_OUT_PATH/extensions/package.json" - mv "$VSCODE_SRC_PATH/extensions/npm-shrinkwrap.json" "$VSCODE_OUT_PATH/extensions/npm-shrinkwrap.json" + cp "$VSCODE_SRC_PATH/extensions/npm-shrinkwrap.json" "$VSCODE_OUT_PATH/extensions/npm-shrinkwrap.json" rsync "$VSCODE_SRC_PATH/extensions/postinstall.mjs" "$VSCODE_OUT_PATH/extensions/postinstall.mjs" } diff --git a/flake.lock b/flake.lock index a200e94e7..5c53c61c0 100644 --- a/flake.lock +++ b/flake.lock @@ -20,18 +20,15 @@ }, "nixpkgs": { "locked": { - "lastModified": 1727104955, - "narHash": "sha256-m6kgjR4zAwyMe1Pn4RGXLCzArtoBp1qzhb2AUlPeVh4=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "d266adc5a77ec8c10ed941c7251b2673004dbd62", - "type": "github" + "lastModified": 1724224976, + "narHash": "sha256-Z/ELQhrSd7bMzTO8r7NZgi9g5emh+aRKoCdaAv5fiO0=", + "path": "/nix/store/j8pbrsb3nybdap3hhg9kw0ffqd4rlbx6-source", + "rev": "c374d94f1536013ca8e92341b540eba4c22f9c62", + "type": "path" }, "original": { - "owner": "nixos", - "ref": "nixos-unstable-small", - "repo": "nixpkgs", - "type": "github" + "id": "nixpkgs", + "type": "indirect" } }, "root": { diff --git a/patches/integration.diff b/patches/integration.diff index 8372cae35..abc9d166a 100644 --- a/patches/integration.diff +++ b/patches/integration.diff @@ -276,14 +276,12 @@ Index: code-server/lib/vscode/src/server-main.js =================================================================== --- code-server.orig/lib/vscode/src/server-main.js +++ code-server/lib/vscode/src/server-main.js -@@ -339,4 +339,9 @@ function prompt(question) { +@@ -339,4 +339,7 @@ function prompt(question) { }); } -start(); -+async function loadCodeWithNls() { ++export default async function loadCodeWithNls() { + const nlsConfiguration = await resolveNLSConfiguration({ userLocale: 'en', osLocale: 'en', commit: product.commit, userDataPath: '', nlsMetadataPath: __dirname }); + return loadCode(nlsConfiguration); +} -+ -+module.exports.loadCodeWithNls = loadCodeWithNls; diff --git a/src/node/routes/vscode.ts b/src/node/routes/vscode.ts index b3f04fd6c..f50f011fd 100644 --- a/src/node/routes/vscode.ts +++ b/src/node/routes/vscode.ts @@ -41,19 +41,25 @@ export interface IVSCodeServerAPI { */ export type VSCodeModule = { // See ../../../lib/vscode/src/server-main.js:339. - loadCodeWithNls(): { + loadCodeWithNls(): Promise<{ // See ../../../lib/vscode/src/vs/server/node/server.main.ts:72. createServer(address: string | net.AddressInfo | null, args: CodeArgs): Promise // See ../../../lib/vscode/src/vs/server/node/server.main.ts:65. spawnCli(args: CodeArgs): Promise - } + }> } /** * Load then create the VS Code server. */ async function loadVSCode(req: express.Request): Promise { - const mod = require(path.join(vsRootPath, "out/server-main")) as VSCodeModule + // Since server-main.js is an ES module, we have to use `import`. However, + // tsc will transpile this to `require` unless we change our module type, + // which will also require that we switch to ESM, since a hybrid approach + // breaks importing `rotating-file-stream` for some reason. To work around + // this, use `eval` for now, but we should consider switching to ESM. + const modPath = path.join(vsRootPath, "out/server-main.js") + const mod = await eval(`import("${modPath}")`) as VSCodeModule const serverModule = await mod.loadCodeWithNls() return serverModule.createServer(null, { ...(await toCodeArgs(req.args)),