mirror of https://github.com/coder/code-server.git
Fix import of server-main.js
This commit is contained in:
parent
184800a94f
commit
e4ceeabe69
|
@ -91,17 +91,17 @@ bundle_vscode() {
|
||||||
|
|
||||||
rsync "${rsync_opts[@]}" ./lib/vscode-reh-web-*/ "$VSCODE_OUT_PATH"
|
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
|
# Merge the package.json for the web/remote server so we can include
|
||||||
# version though so pull that from the main package.json.
|
# dependencies, since we want to ship this via NPM.
|
||||||
jq --slurp '.[0] * {version: .[1].version}' \
|
jq --slurp '.[0] * .[1]' \
|
||||||
"$VSCODE_SRC_PATH/remote/package.json" \
|
"$VSCODE_SRC_PATH/remote/package.json" \
|
||||||
"$VSCODE_SRC_PATH/package.json" > "$VSCODE_OUT_PATH/package.json"
|
"$VSCODE_OUT_PATH/package.json" > "$VSCODE_OUT_PATH/package.json.merged"
|
||||||
|
mv "$VSCODE_OUT_PATH/package.json.merged" "$VSCODE_OUT_PATH/package.json"
|
||||||
mv "$VSCODE_SRC_PATH/remote/npm-shrinkwrap.json" "$VSCODE_OUT_PATH/npm-shrinkwrap.json"
|
cp "$VSCODE_SRC_PATH/remote/npm-shrinkwrap.json" "$VSCODE_OUT_PATH/npm-shrinkwrap.json"
|
||||||
|
|
||||||
# Include global extension dependencies as well.
|
# Include global extension dependencies as well.
|
||||||
rsync "$VSCODE_SRC_PATH/extensions/package.json" "$VSCODE_OUT_PATH/extensions/package.json"
|
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"
|
rsync "$VSCODE_SRC_PATH/extensions/postinstall.mjs" "$VSCODE_OUT_PATH/extensions/postinstall.mjs"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
17
flake.lock
17
flake.lock
|
@ -20,18 +20,15 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1727104955,
|
"lastModified": 1724224976,
|
||||||
"narHash": "sha256-m6kgjR4zAwyMe1Pn4RGXLCzArtoBp1qzhb2AUlPeVh4=",
|
"narHash": "sha256-Z/ELQhrSd7bMzTO8r7NZgi9g5emh+aRKoCdaAv5fiO0=",
|
||||||
"owner": "nixos",
|
"path": "/nix/store/j8pbrsb3nybdap3hhg9kw0ffqd4rlbx6-source",
|
||||||
"repo": "nixpkgs",
|
"rev": "c374d94f1536013ca8e92341b540eba4c22f9c62",
|
||||||
"rev": "d266adc5a77ec8c10ed941c7251b2673004dbd62",
|
"type": "path"
|
||||||
"type": "github"
|
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "nixos",
|
"id": "nixpkgs",
|
||||||
"ref": "nixos-unstable-small",
|
"type": "indirect"
|
||||||
"repo": "nixpkgs",
|
|
||||||
"type": "github"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
|
|
|
@ -276,14 +276,12 @@ Index: code-server/lib/vscode/src/server-main.js
|
||||||
===================================================================
|
===================================================================
|
||||||
--- code-server.orig/lib/vscode/src/server-main.js
|
--- code-server.orig/lib/vscode/src/server-main.js
|
||||||
+++ code-server/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();
|
-start();
|
||||||
+async function loadCodeWithNls() {
|
+export default async function loadCodeWithNls() {
|
||||||
+ const nlsConfiguration = await resolveNLSConfiguration({ userLocale: 'en', osLocale: 'en', commit: product.commit, userDataPath: '', nlsMetadataPath: __dirname });
|
+ const nlsConfiguration = await resolveNLSConfiguration({ userLocale: 'en', osLocale: 'en', commit: product.commit, userDataPath: '', nlsMetadataPath: __dirname });
|
||||||
+ return loadCode(nlsConfiguration);
|
+ return loadCode(nlsConfiguration);
|
||||||
+}
|
+}
|
||||||
+
|
|
||||||
+module.exports.loadCodeWithNls = loadCodeWithNls;
|
|
||||||
|
|
|
@ -41,19 +41,25 @@ export interface IVSCodeServerAPI {
|
||||||
*/
|
*/
|
||||||
export type VSCodeModule = {
|
export type VSCodeModule = {
|
||||||
// See ../../../lib/vscode/src/server-main.js:339.
|
// See ../../../lib/vscode/src/server-main.js:339.
|
||||||
loadCodeWithNls(): {
|
loadCodeWithNls(): Promise<{
|
||||||
// See ../../../lib/vscode/src/vs/server/node/server.main.ts:72.
|
// See ../../../lib/vscode/src/vs/server/node/server.main.ts:72.
|
||||||
createServer(address: string | net.AddressInfo | null, args: CodeArgs): Promise<IVSCodeServerAPI>
|
createServer(address: string | net.AddressInfo | null, args: CodeArgs): Promise<IVSCodeServerAPI>
|
||||||
// See ../../../lib/vscode/src/vs/server/node/server.main.ts:65.
|
// See ../../../lib/vscode/src/vs/server/node/server.main.ts:65.
|
||||||
spawnCli(args: CodeArgs): Promise<void>
|
spawnCli(args: CodeArgs): Promise<void>
|
||||||
}
|
}>
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load then create the VS Code server.
|
* Load then create the VS Code server.
|
||||||
*/
|
*/
|
||||||
async function loadVSCode(req: express.Request): Promise<IVSCodeServerAPI> {
|
async function loadVSCode(req: express.Request): Promise<IVSCodeServerAPI> {
|
||||||
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()
|
const serverModule = await mod.loadCodeWithNls()
|
||||||
return serverModule.createServer(null, {
|
return serverModule.createServer(null, {
|
||||||
...(await toCodeArgs(req.args)),
|
...(await toCodeArgs(req.args)),
|
||||||
|
|
Loading…
Reference in New Issue