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"
|
||||
|
||||
# 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"
|
||||
}
|
||||
|
||||
|
|
17
flake.lock
17
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": {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<IVSCodeServerAPI>
|
||||
// See ../../../lib/vscode/src/vs/server/node/server.main.ts:65.
|
||||
spawnCli(args: CodeArgs): Promise<void>
|
||||
}
|
||||
}>
|
||||
}
|
||||
|
||||
/**
|
||||
* Load then create the VS Code server.
|
||||
*/
|
||||
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()
|
||||
return serverModule.createServer(null, {
|
||||
...(await toCodeArgs(req.args)),
|
||||
|
|
Loading…
Reference in New Issue