esm - inline main entry points (#230135)
parent
fd20b8bb62
commit
e7abf7becb
|
@ -56,9 +56,9 @@ exports.keyboardMaps = [
|
|||
];
|
||||
|
||||
exports.code = [
|
||||
createModuleDescription('vs/code/electron-main/main'),
|
||||
createModuleDescription('vs/code/node/cli'),
|
||||
createModuleDescription('vs/code/node/cliProcessMain', ['vs/code/node/cli']),
|
||||
// 'vs/code/electron-main/main' is not included here because it comes in via ./src/main.js
|
||||
// 'vs/code/node/cli' is not included here because it comes in via ./src/cli.js
|
||||
createModuleDescription('vs/code/node/cliProcessMain'),
|
||||
createModuleDescription('vs/code/electron-utility/sharedProcess/sharedProcessMain'),
|
||||
createModuleDescription('vs/code/electron-sandbox/processExplorer/processExplorerMain')
|
||||
];
|
||||
|
|
|
@ -105,14 +105,8 @@ const serverWithWebResources = [
|
|||
];
|
||||
|
||||
const serverEntryPoints = [
|
||||
{
|
||||
name: 'vs/server/node/server.main',
|
||||
exclude: ['vs/css']
|
||||
},
|
||||
{
|
||||
name: 'vs/server/node/server.cli',
|
||||
exclude: ['vs/css']
|
||||
},
|
||||
// 'vs/server/node/server.main' is not included here because it gets inlined via ./src/server-main.js
|
||||
// 'vs/server/node/server.cli' is not included here because it gets inlined via ./src/server-cli.js
|
||||
{
|
||||
name: 'vs/workbench/api/node/extensionHostProcess',
|
||||
exclude: ['vs/css']
|
||||
|
|
|
@ -263,7 +263,6 @@ const skippedExportMangledFiles = [
|
|||
'pfs',
|
||||
// entry points
|
||||
...[
|
||||
buildfile.entrypoint('vs/server/node/server.main'),
|
||||
buildfile.workerEditor,
|
||||
buildfile.workerExtensionHost,
|
||||
buildfile.workerNotebook,
|
||||
|
|
|
@ -299,7 +299,6 @@ const skippedExportMangledFiles = [
|
|||
|
||||
// entry points
|
||||
...[
|
||||
buildfile.entrypoint('vs/server/node/server.main'),
|
||||
buildfile.workerEditor,
|
||||
buildfile.workerExtensionHost,
|
||||
buildfile.workerNotebook,
|
||||
|
|
|
@ -116,20 +116,8 @@ async function doSetupNLS(): Promise<INLSConfiguration | undefined> {
|
|||
|
||||
//#endregion
|
||||
|
||||
//#region ESM Loading
|
||||
export async function bootstrapESM(): Promise<void> {
|
||||
|
||||
export async function load<T>(esModule: string): Promise<T> {
|
||||
try {
|
||||
// NLS comes first
|
||||
await setupNLS();
|
||||
|
||||
// Then load the ES module
|
||||
return await import([`./${esModule}.js`].join('/') /* workaround to prevent esbuild from inlining this */);
|
||||
} catch (error) {
|
||||
console.error(`Unable to load ${esModule}: ${error}`);
|
||||
throw error;
|
||||
}
|
||||
// NLS
|
||||
await setupNLS();
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
|
|
|
@ -5,39 +5,10 @@
|
|||
|
||||
import * as performance from './vs/base/common/performance.js';
|
||||
import { removeGlobalNodeJsModuleLookupPaths, devInjectNodeModuleLookupPath } from './bootstrap-node.js';
|
||||
import { load } from './bootstrap-esm.js';
|
||||
import { bootstrapESM } from './bootstrap-esm.js';
|
||||
|
||||
performance.mark('code/fork/start');
|
||||
|
||||
// Crash reporter
|
||||
configureCrashReporter();
|
||||
|
||||
// Remove global paths from the node module lookup (node.js only)
|
||||
removeGlobalNodeJsModuleLookupPaths();
|
||||
|
||||
if (process.env['VSCODE_DEV_INJECT_NODE_MODULE_LOOKUP_PATH']) {
|
||||
devInjectNodeModuleLookupPath(process.env['VSCODE_DEV_INJECT_NODE_MODULE_LOOKUP_PATH']);
|
||||
}
|
||||
|
||||
// Configure: pipe logging to parent process
|
||||
if (!!process.send && process.env['VSCODE_PIPE_LOGGING'] === 'true') {
|
||||
pipeLoggingToParent();
|
||||
}
|
||||
|
||||
// Handle Exceptions
|
||||
if (!process.env['VSCODE_HANDLES_UNCAUGHT_ERRORS']) {
|
||||
handleExceptions();
|
||||
}
|
||||
|
||||
// Terminate when parent terminates
|
||||
if (process.env['VSCODE_PARENT_PID']) {
|
||||
terminateWhenParentTerminates();
|
||||
}
|
||||
|
||||
// Load ESM entry point
|
||||
load(process.env['VSCODE_ESM_ENTRYPOINT']!);
|
||||
|
||||
|
||||
//#region Helpers
|
||||
|
||||
function pipeLoggingToParent(): void {
|
||||
|
@ -225,3 +196,34 @@ function configureCrashReporter(): void {
|
|||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
// Crash reporter
|
||||
configureCrashReporter();
|
||||
|
||||
// Remove global paths from the node module lookup (node.js only)
|
||||
removeGlobalNodeJsModuleLookupPaths();
|
||||
|
||||
if (process.env['VSCODE_DEV_INJECT_NODE_MODULE_LOOKUP_PATH']) {
|
||||
devInjectNodeModuleLookupPath(process.env['VSCODE_DEV_INJECT_NODE_MODULE_LOOKUP_PATH']);
|
||||
}
|
||||
|
||||
// Configure: pipe logging to parent process
|
||||
if (!!process.send && process.env['VSCODE_PIPE_LOGGING'] === 'true') {
|
||||
pipeLoggingToParent();
|
||||
}
|
||||
|
||||
// Handle Exceptions
|
||||
if (!process.env['VSCODE_HANDLES_UNCAUGHT_ERRORS']) {
|
||||
handleExceptions();
|
||||
}
|
||||
|
||||
// Terminate when parent terminates
|
||||
if (process.env['VSCODE_PARENT_PID']) {
|
||||
terminateWhenParentTerminates();
|
||||
}
|
||||
|
||||
// Bootstrap ESM
|
||||
await bootstrapESM();
|
||||
|
||||
// Load ESM entry point
|
||||
await import([`./${process.env['VSCODE_ESM_ENTRYPOINT']}.js`].join('/') /* workaround: esbuild prints some strange warnings when trying to inline? */);
|
||||
|
|
|
@ -7,7 +7,7 @@ import './bootstrap-cli.js'; // this MUST come before other imports as it change
|
|||
import { dirname } from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { configurePortable } from './bootstrap-node.js';
|
||||
import { load } from './bootstrap-esm.js';
|
||||
import { bootstrapESM } from './bootstrap-esm.js';
|
||||
import { resolveNLSConfiguration } from './vs/base/node/nls.js';
|
||||
import { product } from './bootstrap-meta.js';
|
||||
|
||||
|
@ -23,5 +23,8 @@ configurePortable(product);
|
|||
// Signal processes that we got launched as CLI
|
||||
process.env['VSCODE_CLI'] = '1';
|
||||
|
||||
// Load CLI
|
||||
load('vs/code/node/cli');
|
||||
// Bootstrap ESM
|
||||
await bootstrapESM();
|
||||
|
||||
// Load Server
|
||||
await import('./vs/code/node/cli.js');
|
||||
|
|
|
@ -7,7 +7,7 @@ import * as path from 'path';
|
|||
import * as fs from 'original-fs';
|
||||
import * as os from 'os';
|
||||
import { configurePortable } from './bootstrap-node.js';
|
||||
import { load } from './bootstrap-esm.js';
|
||||
import { bootstrapESM } from './bootstrap-esm.js';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { app, protocol, crashReporter, Menu, contentTracing } from 'electron';
|
||||
import minimist from 'minimist';
|
||||
|
@ -173,8 +173,12 @@ async function startup(codeCachePath: string | undefined, nlsConfig: INLSConfigu
|
|||
process.env['VSCODE_NLS_CONFIG'] = JSON.stringify(nlsConfig);
|
||||
process.env['VSCODE_CODE_CACHE_PATH'] = codeCachePath || '';
|
||||
|
||||
// Bootstrap ESM
|
||||
await bootstrapESM();
|
||||
|
||||
// Load Main
|
||||
perf.mark('code/willLoadMainBundle');
|
||||
await load('vs/code/electron-main/main');
|
||||
await import('./vs/code/electron-main/main.js');
|
||||
perf.mark('code/didLoadMainBundle');
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import './bootstrap-server.js'; // this MUST come before other imports as it cha
|
|||
import { dirname, join } from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { devInjectNodeModuleLookupPath } from './bootstrap-node.js';
|
||||
import { load } from './bootstrap-esm.js';
|
||||
import { bootstrapESM } from './bootstrap-esm.js';
|
||||
import { resolveNLSConfiguration } from './vs/base/node/nls.js';
|
||||
import { product } from './bootstrap-meta.js';
|
||||
|
||||
|
@ -26,5 +26,8 @@ if (process.env['VSCODE_DEV']) {
|
|||
delete process.env['VSCODE_DEV_INJECT_NODE_MODULE_LOOKUP_PATH'];
|
||||
}
|
||||
|
||||
// Load Server CLI
|
||||
load('vs/server/node/server.cli');
|
||||
// Bootstrap ESM
|
||||
await bootstrapESM();
|
||||
|
||||
// Load Server
|
||||
await import('./vs/server/node/server.cli');
|
||||
|
|
|
@ -13,7 +13,7 @@ import { performance } from 'perf_hooks';
|
|||
import { fileURLToPath } from 'url';
|
||||
import minimist from 'minimist';
|
||||
import { devInjectNodeModuleLookupPath } from './bootstrap-node.js';
|
||||
import { load } from './bootstrap-esm.js';
|
||||
import { 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';
|
||||
|
@ -227,7 +227,7 @@ async function findFreePort(host: string | undefined, start: number, end: number
|
|||
return undefined;
|
||||
}
|
||||
|
||||
function loadCode(nlsConfiguration: INLSConfiguration): Promise<typeof import('./vs/server/node/server.main.js')> {
|
||||
async function loadCode(nlsConfiguration: INLSConfiguration) {
|
||||
|
||||
// required for `bootstrap-esm` to pick up NLS messages
|
||||
process.env['VSCODE_NLS_CONFIG'] = JSON.stringify(nlsConfiguration);
|
||||
|
@ -247,8 +247,11 @@ function loadCode(nlsConfiguration: INLSConfiguration): Promise<typeof import('.
|
|||
delete process.env['VSCODE_DEV_INJECT_NODE_MODULE_LOOKUP_PATH'];
|
||||
}
|
||||
|
||||
// Bootstrap ESM
|
||||
await bootstrapESM();
|
||||
|
||||
// Load Server
|
||||
return load<typeof import('./vs/server/node/server.main.js')>('vs/server/node/server.main');
|
||||
return import('./vs/server/node/server.main.js');
|
||||
}
|
||||
|
||||
function hasStdinWithoutTty(): boolean {
|
||||
|
|
|
@ -117,7 +117,20 @@ export async function main(argv: string[]): Promise<any> {
|
|||
|
||||
// Extensions Management
|
||||
else if (shouldSpawnCliProcess(args)) {
|
||||
const cli = await import(['./cliProcessMain.js'].join('/') /* workaround to prevent esbuild from inlining this */);
|
||||
|
||||
// We do not bundle `cliProcessMain.js` into this file because
|
||||
// it is rather large and only needed for very few CLI operations.
|
||||
// This has the downside that we need to know if we run OSS or
|
||||
// built, because our location on disk is different if built.
|
||||
|
||||
let cliProcessMain: string;
|
||||
if (process.env['VSCODE_DEV']) {
|
||||
cliProcessMain = './cliProcessMain.js';
|
||||
} else {
|
||||
cliProcessMain = './vs/code/node/cliProcessMain.js';
|
||||
}
|
||||
|
||||
const cli = await import(cliProcessMain);
|
||||
await cli.main(args);
|
||||
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue