diff --git a/.eslintrc.json b/.eslintrc.json index 65e29fc3f85..db1594ec4b2 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1133,7 +1133,7 @@ "restrictions": [] }, { - "target": "src/{bootstrap-amd.js,bootstrap-fork.js,bootstrap-node.js,bootstrap-window.js,cli.js,main.js,server-cli.js,server-main.js,bootstrap-cli.js,bootstrap-server.js}", + "target": "src/{bootstrap-esm.js,bootstrap-fork.js,bootstrap-node.js,bootstrap-window.js,cli.js,main.js,server-cli.js,server-main.js,bootstrap-cli.js,bootstrap-server.js}", "restrictions": [] } ] diff --git a/src/bootstrap-amd.js b/src/bootstrap-esm.js similarity index 93% rename from src/bootstrap-amd.js rename to src/bootstrap-esm.js index c33c8c547f6..5ea55cbabe4 100644 --- a/src/bootstrap-amd.js +++ b/src/bootstrap-esm.js @@ -80,7 +80,7 @@ function setupNLS() { * @returns {Promise} */ async function doSetupNLS() { - performance.mark('code/amd/willLoadNls'); + performance.mark('code/willLoadNls'); /** @type {INLSConfiguration | undefined} */ let nlsConfig = undefined; @@ -134,33 +134,31 @@ async function doSetupNLS() { } } - performance.mark('code/amd/didLoadNls'); + performance.mark('code/didLoadNls'); return nlsConfig; } //#endregion -//#region Loader Config +//#region ESM Loading /** - * @param {string=} entrypoint + * @param {string=} esModule * @param {(value: any) => void} [onLoad] * @param {(err: Error) => void} [onError] */ -module.exports.load = function (entrypoint, onLoad, onError) { - if (!entrypoint) { +module.exports.load = function (esModule, onLoad, onError) { + if (!esModule) { return; } - entrypoint = `./${entrypoint}.js`; - onLoad = onLoad || function () { }; onError = onError || function (err) { console.error(err); }; setupNLS().then(() => { performance.mark(`code/fork/willLoadCode`); - import(entrypoint).then(onLoad, onError); + import([`./${esModule}.js`].join('/') /* TODO@esm workaround to prevent esbuild from inlining this */).then(onLoad, onError); }); }; diff --git a/src/bootstrap-fork.js b/src/bootstrap-fork.js index e8dd31410b0..ccec476cc66 100644 --- a/src/bootstrap-fork.js +++ b/src/bootstrap-fork.js @@ -8,7 +8,7 @@ import * as performance from './vs/base/common/performance.js'; import * as bootstrapNode from './bootstrap-node.js'; -import * as bootstrapAmd from './bootstrap-amd.js'; +import * as bootstrapESM from './bootstrap-esm.js'; performance.mark('code/fork/start'); @@ -37,8 +37,8 @@ if (process.env['VSCODE_PARENT_PID']) { terminateWhenParentTerminates(); } -// Load AMD entry point -bootstrapAmd.load(process.env['VSCODE_AMD_ENTRYPOINT']); +// Load ESM entry point +bootstrapESM.load(process.env['VSCODE_ESM_ENTRYPOINT']); //#region Helpers diff --git a/src/bootstrap-server.js b/src/bootstrap-server.js index b84cc6a6ef6..1e489a31478 100644 --- a/src/bootstrap-server.js +++ b/src/bootstrap-server.js @@ -6,5 +6,5 @@ //@ts-check 'use strict'; -// Keep bootstrap-amd.js from redefining 'fs'. +// Keep bootstrap-esm.js from redefining 'fs'. delete process.env['ELECTRON_RUN_AS_NODE']; diff --git a/src/cli.js b/src/cli.js index 4779558cbed..f7f4ac433d0 100644 --- a/src/cli.js +++ b/src/cli.js @@ -10,7 +10,7 @@ import './bootstrap-cli.js'; // this MUST come before other imports as it change import * as path from 'path'; import { fileURLToPath } from 'url'; import * as bootstrapNode from './bootstrap-node.js'; -import * as bootstrapAmd from './bootstrap-amd.js'; +import * as bootstrapESM from './bootstrap-esm.js'; import { resolveNLSConfiguration } from './vs/base/node/nls.js'; import { product } from './bootstrap-meta.js'; @@ -20,7 +20,7 @@ async function start() { // NLS const nlsConfiguration = await resolveNLSConfiguration({ userLocale: 'en', osLocale: 'en', commit: product.commit, userDataPath: '', nlsMetadataPath: __dirname }); - process.env['VSCODE_NLS_CONFIG'] = JSON.stringify(nlsConfiguration); // required for `bootstrap-amd` to pick up NLS messages + process.env['VSCODE_NLS_CONFIG'] = JSON.stringify(nlsConfiguration); // required for `bootstrap-esm` to pick up NLS messages // Enable portable support // @ts-ignore @@ -29,8 +29,8 @@ async function start() { // Signal processes that we got launched as CLI process.env['VSCODE_CLI'] = '1'; - // Load CLI through AMD loader - bootstrapAmd.load('vs/code/node/cli'); + // Load CLI + bootstrapESM.load('vs/code/node/cli'); } start(); diff --git a/src/main.js b/src/main.js index f1874ff940c..5045aa1201f 100644 --- a/src/main.js +++ b/src/main.js @@ -15,7 +15,7 @@ import * as path from 'path'; import * as fs from 'original-fs'; import * as os from 'os'; import * as bootstrapNode from './bootstrap-node.js'; -import * as bootstrapAmd from './bootstrap-amd.js'; +import * as bootstrapESM from './bootstrap-esm.js'; import { fileURLToPath } from 'url'; import { app, protocol, crashReporter, Menu, contentTracing } from 'electron'; import minimist from 'minimist'; @@ -184,9 +184,8 @@ function startup(codeCachePath, nlsConfig) { process.env['VSCODE_NLS_CONFIG'] = JSON.stringify(nlsConfig); process.env['VSCODE_CODE_CACHE_PATH'] = codeCachePath || ''; - // Load main in AMD perf.mark('code/willLoadMainBundle'); - bootstrapAmd.load('vs/code/electron-main/main', () => { + bootstrapESM.load('vs/code/electron-main/main', () => { perf.mark('code/didLoadMainBundle'); }); } diff --git a/src/server-cli.js b/src/server-cli.js index e2f1907eb19..b3ad8d0a2c6 100644 --- a/src/server-cli.js +++ b/src/server-cli.js @@ -10,7 +10,7 @@ import './bootstrap-server.js'; // this MUST come before other imports as it cha import * as path from 'path'; import { fileURLToPath } from 'url'; import * as bootstrapNode from './bootstrap-node.js'; -import * as bootstrapAmd from './bootstrap-amd.js'; +import * as bootstrapESM from './bootstrap-esm.js'; import { resolveNLSConfiguration } from './vs/base/node/nls.js'; import { product } from './bootstrap-meta.js'; @@ -20,7 +20,7 @@ async function start() { // NLS const nlsConfiguration = await resolveNLSConfiguration({ userLocale: 'en', osLocale: 'en', commit: product.commit, userDataPath: '', nlsMetadataPath: __dirname }); - process.env['VSCODE_NLS_CONFIG'] = JSON.stringify(nlsConfiguration); // required for `bootstrap-amd` to pick up NLS messages + process.env['VSCODE_NLS_CONFIG'] = JSON.stringify(nlsConfiguration); // required for `bootstrap-esm` to pick up NLS messages if (process.env['VSCODE_DEV']) { // When running out of sources, we need to load node modules from remote/node_modules, @@ -30,7 +30,9 @@ async function start() { } else { delete process.env['VSCODE_DEV_INJECT_NODE_MODULE_LOOKUP_PATH']; } - bootstrapAmd.load('vs/server/node/server.cli'); + + // Load Server CLI + bootstrapESM.load('vs/server/node/server.cli'); } start(); diff --git a/src/server-main.js b/src/server-main.js index e93ae4189d0..f87f5287aca 100644 --- a/src/server-main.js +++ b/src/server-main.js @@ -20,7 +20,7 @@ import { performance } from 'perf_hooks'; import { fileURLToPath } from 'url'; import minimist from 'minimist'; import * as bootstrapNode from './bootstrap-node.js'; -import * as bootstrapAmd from './bootstrap-amd.js'; +import * as bootstrapESM from './bootstrap-esm.js'; import { resolveNLSConfiguration } from './vs/base/node/nls.js'; import { product } from './bootstrap-meta.js'; import * as perf from './vs/base/common/performance.js'; @@ -267,7 +267,7 @@ function loadCode(nlsConfiguration) { return new Promise((resolve, reject) => { /** @type {INLSConfiguration} */ - process.env['VSCODE_NLS_CONFIG'] = JSON.stringify(nlsConfiguration); // required for `bootstrap-amd` to pick up NLS messages + process.env['VSCODE_NLS_CONFIG'] = JSON.stringify(nlsConfiguration); // required for `bootstrap-esm` to pick up NLS messages // See https://github.com/microsoft/vscode-remote-release/issues/6543 // We would normally install a SIGPIPE listener in bootstrap-node.js @@ -283,7 +283,9 @@ function loadCode(nlsConfiguration) { } else { delete process.env['VSCODE_DEV_INJECT_NODE_MODULE_LOOKUP_PATH']; } - bootstrapAmd.load('vs/server/node/server.main', resolve, reject); + + // Load Server + bootstrapESM.load('vs/server/node/server.main', resolve, reject); }); } diff --git a/src/tsconfig.json b/src/tsconfig.json index 88514beab2e..95fa3769122 100644 --- a/src/tsconfig.json +++ b/src/tsconfig.json @@ -26,8 +26,8 @@ ] }, "include": [ - "./bootstrap-amd.js", "./bootstrap-cli.js", + "./bootstrap-esm.js", "./bootstrap-fork.js", "./bootstrap-import.js", "./bootstrap-meta.js", diff --git a/src/vs/base/parts/ipc/test/node/ipc.cp.integrationTest.ts b/src/vs/base/parts/ipc/test/node/ipc.cp.integrationTest.ts index 9e74f43168e..e43dc5be0b1 100644 --- a/src/vs/base/parts/ipc/test/node/ipc.cp.integrationTest.ts +++ b/src/vs/base/parts/ipc/test/node/ipc.cp.integrationTest.ts @@ -13,7 +13,7 @@ import { FileAccess } from '../../../../common/network.js'; function createClient(): Client { return new Client(FileAccess.asFileUri('bootstrap-fork').fsPath, { serverName: 'TestServer', - env: { VSCODE_AMD_ENTRYPOINT: 'vs/base/parts/ipc/test/node/testApp', verbose: true } + env: { VSCODE_ESM_ENTRYPOINT: 'vs/base/parts/ipc/test/node/testApp', verbose: true } }); } diff --git a/src/vs/base/test/node/processes/processes.integrationTest.ts b/src/vs/base/test/node/processes/processes.integrationTest.ts index 8057a120606..3f30e931271 100644 --- a/src/vs/base/test/node/processes/processes.integrationTest.ts +++ b/src/vs/base/test/node/processes/processes.integrationTest.ts @@ -13,7 +13,7 @@ import * as processes from '../../../node/processes.js'; function fork(id: string): cp.ChildProcess { const opts: any = { env: objects.mixin(objects.deepClone(process.env), { - VSCODE_AMD_ENTRYPOINT: id, + VSCODE_ESM_ENTRYPOINT: id, VSCODE_PIPE_LOGGING: 'true', VSCODE_VERBOSE_LOGGING: true }) diff --git a/src/vs/code/node/cli.ts b/src/vs/code/node/cli.ts index 6f502f20d87..f730cfe4507 100644 --- a/src/vs/code/node/cli.ts +++ b/src/vs/code/node/cli.ts @@ -58,7 +58,7 @@ export async function main(argv: string[]): Promise { const env: IProcessEnvironment = { ...process.env }; - // bootstrap-amd.js determines the electron environment based + // bootstrap-esm.js determines the electron environment based // on the following variable. For the server we need to unset // it to prevent importing any electron specific modules. // Refs https://github.com/microsoft/vscode/issues/221883 diff --git a/src/vs/platform/files/node/watcher/watcherClient.ts b/src/vs/platform/files/node/watcher/watcherClient.ts index f14e8c4dd8e..b88b7f32004 100644 --- a/src/vs/platform/files/node/watcher/watcherClient.ts +++ b/src/vs/platform/files/node/watcher/watcherClient.ts @@ -32,7 +32,7 @@ export class UniversalWatcherClient extends AbstractUniversalWatcherClient { serverName: 'File Watcher', args: ['--type=fileWatcher'], env: { - VSCODE_AMD_ENTRYPOINT: 'vs/platform/files/node/watcher/watcherMain', + VSCODE_ESM_ENTRYPOINT: 'vs/platform/files/node/watcher/watcherMain', VSCODE_PIPE_LOGGING: 'true', VSCODE_VERBOSE_LOGGING: 'true' // transmit console logs from server to client } diff --git a/src/vs/platform/telemetry/node/customEndpointTelemetryService.ts b/src/vs/platform/telemetry/node/customEndpointTelemetryService.ts index 894ff8cca30..233b79f96b1 100644 --- a/src/vs/platform/telemetry/node/customEndpointTelemetryService.ts +++ b/src/vs/platform/telemetry/node/customEndpointTelemetryService.ts @@ -43,7 +43,7 @@ export class CustomEndpointTelemetryService implements ICustomEndpointTelemetryS env: { ELECTRON_RUN_AS_NODE: 1, VSCODE_PIPE_LOGGING: 'true', - VSCODE_AMD_ENTRYPOINT: 'vs/workbench/contrib/debug/node/telemetryApp' + VSCODE_ESM_ENTRYPOINT: 'vs/workbench/contrib/debug/node/telemetryApp' } } ); diff --git a/src/vs/platform/terminal/electron-main/electronPtyHostStarter.ts b/src/vs/platform/terminal/electron-main/electronPtyHostStarter.ts index 607bd9b3a37..d4835c5879f 100644 --- a/src/vs/platform/terminal/electron-main/electronPtyHostStarter.ts +++ b/src/vs/platform/terminal/electron-main/electronPtyHostStarter.ts @@ -85,7 +85,7 @@ export class ElectronPtyHostStarter extends Disposable implements IPtyHostStarte this._environmentMainService.unsetSnapExportedVariables(); const config: { [key: string]: string } = { ...deepClone(process.env), - VSCODE_AMD_ENTRYPOINT: 'vs/platform/terminal/node/ptyHostMain', + VSCODE_ESM_ENTRYPOINT: 'vs/platform/terminal/node/ptyHostMain', VSCODE_PIPE_LOGGING: 'true', VSCODE_VERBOSE_LOGGING: 'true', // transmit console logs from server to client, VSCODE_RECONNECT_GRACE_TIME: String(this._reconnectConstants.graceTime), diff --git a/src/vs/platform/terminal/node/nodePtyHostStarter.ts b/src/vs/platform/terminal/node/nodePtyHostStarter.ts index bc78aa5d8a6..707f1ca887b 100644 --- a/src/vs/platform/terminal/node/nodePtyHostStarter.ts +++ b/src/vs/platform/terminal/node/nodePtyHostStarter.ts @@ -24,7 +24,7 @@ export class NodePtyHostStarter extends Disposable implements IPtyHostStarter { serverName: 'Pty Host', args: ['--type=ptyHost', '--logsPath', this._environmentService.logsHome.with({ scheme: Schemas.file }).fsPath], env: { - VSCODE_AMD_ENTRYPOINT: 'vs/platform/terminal/node/ptyHostMain', + VSCODE_ESM_ENTRYPOINT: 'vs/platform/terminal/node/ptyHostMain', VSCODE_PIPE_LOGGING: 'true', VSCODE_VERBOSE_LOGGING: 'true', // transmit console logs from server to client, VSCODE_RECONNECT_GRACE_TIME: this._reconnectConstants.graceTime, diff --git a/src/vs/platform/utilityProcess/electron-main/utilityProcess.ts b/src/vs/platform/utilityProcess/electron-main/utilityProcess.ts index 1386e87f2b5..199813a3b8c 100644 --- a/src/vs/platform/utilityProcess/electron-main/utilityProcess.ts +++ b/src/vs/platform/utilityProcess/electron-main/utilityProcess.ts @@ -264,7 +264,7 @@ export class UtilityProcess extends Disposable { const env: { [key: string]: any } = configuration.env ? { ...configuration.env } : { ...deepClone(process.env) }; // Apply supported environment variables from config - env['VSCODE_AMD_ENTRYPOINT'] = configuration.entryPoint; + env['VSCODE_ESM_ENTRYPOINT'] = configuration.entryPoint; if (typeof configuration.parentLifecycleBound === 'number') { env['VSCODE_PARENT_PID'] = String(configuration.parentLifecycleBound); } diff --git a/src/vs/server/node/extensionHostConnection.ts b/src/vs/server/node/extensionHostConnection.ts index ab484be52a9..a3584893505 100644 --- a/src/vs/server/node/extensionHostConnection.ts +++ b/src/vs/server/node/extensionHostConnection.ts @@ -41,7 +41,7 @@ export async function buildUserEnvironment(startParamsEnv: { [key: string]: stri ...processEnv, ...userShellEnv, ...{ - VSCODE_AMD_ENTRYPOINT: 'vs/workbench/api/node/extensionHostProcess', + VSCODE_ESM_ENTRYPOINT: 'vs/workbench/api/node/extensionHostProcess', VSCODE_HANDLES_UNCAUGHT_ERRORS: 'true', VSCODE_NLS_CONFIG: JSON.stringify(nlsConfig) }, diff --git a/src/vs/workbench/services/extensions/electron-sandbox/localProcessExtensionHost.ts b/src/vs/workbench/services/extensions/electron-sandbox/localProcessExtensionHost.ts index 0d16b8838bc..e62e021ae8d 100644 --- a/src/vs/workbench/services/extensions/electron-sandbox/localProcessExtensionHost.ts +++ b/src/vs/workbench/services/extensions/electron-sandbox/localProcessExtensionHost.ts @@ -191,7 +191,7 @@ export class NativeLocalProcessExtensionHost implements IExtensionHost { this._extensionHostProcess = new ExtensionHostProcess(extensionHostCreationResult.id, this._extensionHostStarter); const env = objects.mixin(processEnv, { - VSCODE_AMD_ENTRYPOINT: 'vs/workbench/api/node/extensionHostProcess', + VSCODE_ESM_ENTRYPOINT: 'vs/workbench/api/node/extensionHostProcess', VSCODE_HANDLES_UNCAUGHT_ERRORS: true });