@@ -272,15 +272,71 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
272272 embedderIdentifier: 'server-distro',
273273 extensionsGallery: this._webExtensionResourceUrlTemplate && this._productService.extensionsGallery ? {
274274 ...this._productService.extensionsGallery,
275- Index: code-server/lib/vscode/src/server-main .js
275+ Index: code-server/lib/vscode/src/code-server .js
276276===================================================================
277- --- code-server.orig/lib/vscode/src/server-main.js
278- +++ code-server/lib/vscode/src/server-main.js
279- @@ -339,4 +339,9 @@ function prompt(question) {
280- });
281- }
282-
283- - start();
277+ --- /dev/null
278+ +++ code-server/lib/vscode/src/code-server.js
279+ @@ -0,0 +1,66 @@
280+ + // This is a copy of server-main.js (the parts we use), before it was converted
281+ + // to ESM. Directly importing it in code-server has proven difficult. We will
282+ + // need to to consider some new options going forward.
283+ + //
284+ + // 1. Convert code-server to ESM (best option?).
285+ + // 2. Do not import, fork a process, and communicate via IPC.
286+ +
287+ + // @ts-check
288+ + 'use strict';
289+ +
290+ + /**
291+ + * @import { INLSConfiguration } from './vs/nls'
292+ + */
293+ +
294+ + // Keep bootstrap-amd.js from redefining 'fs'.
295+ + delete process.env['ELECTRON_RUN_AS_NODE'];
296+ +
297+ + const path = require('path');
298+ + const performance = require('perf_hooks').performance;
299+ + const bootstrapNode = require('./bootstrap-node');
300+ + const bootstrapAmd = require('./bootstrap-amd');
301+ + const { resolveNLSConfiguration } = require('./vs/base/node/nls');
302+ + const product = require('./bootstrap-meta').product;
303+ + const perf = require(`./vs/base/common/performance`);
304+ +
305+ + perf.mark('code/server/start');
306+ + // @ts-ignore
307+ + global.vscodeServerStartTime = performance.now();
308+ +
309+ + /**
310+ + * @param {INLSConfiguration} nlsConfiguration
311+ + * @returns { Promise<typeof import('./vs/server/node/server.main')> }
312+ + */
313+ + function loadCode(nlsConfiguration) {
314+ + return new Promise((resolve, reject) => {
315+ +
316+ + /** @type {INLSConfiguration} */
317+ + process.env['VSCODE_NLS_CONFIG'] = JSON.stringify(nlsConfiguration); // required for `bootstrap-amd` to pick up NLS messages
318+ +
319+ + // See https://github.com/microsoft/vscode-remote-release/issues/6543
320+ + // We would normally install a SIGPIPE listener in bootstrap-node.js
321+ + // But in certain situations, the console itself can be in a broken pipe state
322+ + // so logging SIGPIPE to the console will cause an infinite async loop
323+ + process.env['VSCODE_HANDLES_SIGPIPE'] = 'true';
324+ +
325+ + if (process.env['VSCODE_DEV']) {
326+ + // When running out of sources, we need to load node modules from remote/node_modules,
327+ + // which are compiled against nodejs, not electron
328+ + process.env['VSCODE_DEV_INJECT_NODE_MODULE_LOOKUP_PATH'] = process.env['VSCODE_DEV_INJECT_NODE_MODULE_LOOKUP_PATH'] || path.join(__dirname, '..', 'remote', 'node_modules');
329+ + bootstrapNode.devInjectNodeModuleLookupPath(process.env['VSCODE_DEV_INJECT_NODE_MODULE_LOOKUP_PATH']);
330+ + } else {
331+ + delete process.env['VSCODE_DEV_INJECT_NODE_MODULE_LOOKUP_PATH'];
332+ + }
333+ + bootstrapAmd.load('vs/server/node/server.main', resolve, reject);
334+ + });
335+ + }
336+ +
337+ + /**
338+ + * @returns { Promise<typeof import('./vs/server/node/server.main')> }
339+ + */
284340+ async function loadCodeWithNls() {
285341+ const nlsConfiguration = await resolveNLSConfiguration({ userLocale: 'en', osLocale: 'en', commit: product.commit, userDataPath: '', nlsMetadataPath: __dirname });
286342+ return loadCode(nlsConfiguration);
0 commit comments