esm - reduce diff to branch (#221154)

This commit is contained in:
Benjamin Pasero
2024-07-09 08:08:56 +02:00
committed by GitHub
parent 2fe0527205
commit 16654e6126
31 changed files with 650 additions and 198 deletions

View File

@@ -69,4 +69,3 @@ function startServer(programArgs) {
} }
main(); main();

116
src/bootstrap-amd.js vendored
View File

@@ -7,10 +7,28 @@
'use strict'; 'use strict';
/** /**
* @typedef {import('./vs/nls').INLSConfiguration} INLSConfiguration * @import { INLSConfiguration } from './vs/nls'
* @import { IProductConfiguration } from './vs/base/common/product' * @import { IProductConfiguration } from './vs/base/common/product'
*/ */
// ESM-comment-begin
const isESM = false;
// ESM-comment-end
// ESM-uncomment-begin
// import * as path from 'path';
// import * as fs from 'fs';
// import { fileURLToPath } from 'url';
// import { createRequire } from 'node:module';
// import { product, pkg } from './bootstrap-meta.js';
// import * as bootstrap from './bootstrap.js';
// import * as performance from './vs/base/common/performance.js';
//
// const require = createRequire(import.meta.url);
// const isESM = true;
// const module = { exports: {} };
// const __dirname = path.dirname(fileURLToPath(import.meta.url));
// ESM-uncomment-end
// Store the node.js require function in a variable // Store the node.js require function in a variable
// before loading our AMD loader to avoid issues // before loading our AMD loader to avoid issues
// when this file is bundled with other files. // when this file is bundled with other files.
@@ -21,7 +39,12 @@ globalThis._VSCODE_NODE_MODULES = new Proxy(Object.create(null), { get: (_target
// VSCODE_GLOBALS: package/product.json // VSCODE_GLOBALS: package/product.json
/** @type Partial<IProductConfiguration> */ /** @type Partial<IProductConfiguration> */
// ESM-comment-begin
globalThis._VSCODE_PRODUCT_JSON = require('./bootstrap-meta').product; globalThis._VSCODE_PRODUCT_JSON = require('./bootstrap-meta').product;
// ESM-comment-end
// ESM-uncomment-begin
// globalThis._VSCODE_PRODUCT_JSON = { ...product };
// ESM-uncomment-end
if (process.env['VSCODE_DEV']) { if (process.env['VSCODE_DEV']) {
// Patch product overrides when running out of sources // Patch product overrides when running out of sources
try { try {
@@ -30,29 +53,21 @@ if (process.env['VSCODE_DEV']) {
globalThis._VSCODE_PRODUCT_JSON = Object.assign(globalThis._VSCODE_PRODUCT_JSON, overrides); globalThis._VSCODE_PRODUCT_JSON = Object.assign(globalThis._VSCODE_PRODUCT_JSON, overrides);
} catch (error) { /* ignore */ } } catch (error) { /* ignore */ }
} }
// ESM-comment-begin
globalThis._VSCODE_PACKAGE_JSON = require('./bootstrap-meta').pkg; globalThis._VSCODE_PACKAGE_JSON = require('./bootstrap-meta').pkg;
// ESM-comment-end
// ESM-uncomment-begin
// globalThis._VSCODE_PACKAGE_JSON = { ...pkg };
// ESM-uncomment-end
// @ts-ignore // VSCODE_GLOBALS: file root of all resources
const loader = require('./vs/loader'); globalThis._VSCODE_FILE_ROOT = __dirname;
// ESM-comment-begin
const bootstrap = require('./bootstrap'); const bootstrap = require('./bootstrap');
const performance = require('./vs/base/common/performance'); const performance = require(`./vs/base/common/performance`);
const fs = require('fs'); const fs = require('fs');
// ESM-comment-end
// Bootstrap: Loader
loader.config({
baseUrl: bootstrap.fileUriFromPath(__dirname, { isWindows: process.platform === 'win32' }),
catchError: true,
nodeRequire,
amdModulesPattern: /^vs\//,
recordStats: true
});
// Running in Electron
if (process.env['ELECTRON_RUN_AS_NODE'] || process.versions['electron']) {
loader.define('fs', ['original-fs'], function (/** @type {import('fs')} */originalFS) {
return originalFS; // replace the patched electron fs with the original node fs for all AMD code
});
}
//#region NLS helpers //#region NLS helpers
@@ -138,12 +153,56 @@ async function doSetupNLS() {
//#endregion //#endregion
/** //#region Loader Config
if (isESM) {
/**
* @param {string=} entrypoint * @param {string=} entrypoint
* @param {(value: any) => void=} onLoad * @param {(value: any) => void} [onLoad]
* @param {(err: Error) => void=} onError * @param {(err: Error) => void} [onError]
*/ */
exports.load = function (entrypoint, onLoad, onError) { module.exports.load = function (entrypoint, onLoad, onError) {
if (!entrypoint) {
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);
});
};
} else {
// @ts-ignore
const loader = require('./vs/loader');
loader.config({
baseUrl: bootstrap.fileUriFromPath(__dirname, { isWindows: process.platform === 'win32' }),
catchError: true,
nodeRequire,
amdModulesPattern: /^vs\//,
recordStats: true
});
// Running in Electron
if (process.env['ELECTRON_RUN_AS_NODE'] || process.versions['electron']) {
loader.define('fs', ['original-fs'], function (/** @type {import('fs')} */originalFS) {
return originalFS; // replace the patched electron fs with the original node fs for all AMD code
});
}
/**
* @param {string=} entrypoint
* @param {(value: any) => void} [onLoad]
* @param {(err: Error) => void} [onError]
*/
module.exports.load = function (entrypoint, onLoad, onError) {
if (!entrypoint) { if (!entrypoint) {
return; return;
} }
@@ -165,4 +224,11 @@ exports.load = function (entrypoint, onLoad, onError) {
performance.mark('code/fork/willLoadCode'); performance.mark('code/fork/willLoadCode');
loader([entrypoint], onLoad, onError); loader([entrypoint], onLoad, onError);
}); });
}; };
}
//#endregion
// ESM-uncomment-begin
// export const load = module.exports.load;
// ESM-uncomment-end

15
src/bootstrap-fork.js vendored
View File

@@ -6,11 +6,20 @@
//@ts-check //@ts-check
'use strict'; 'use strict';
// ESM-comment-begin
const performance = require('./vs/base/common/performance'); const performance = require('./vs/base/common/performance');
performance.mark('code/fork/start');
const bootstrap = require('./bootstrap'); const bootstrap = require('./bootstrap');
const bootstrapNode = require('./bootstrap-node'); const bootstrapNode = require('./bootstrap-node');
const bootstrapAmd = require('./bootstrap-amd');
// ESM-comment-end
// ESM-uncomment-begin
// import * as performance from './vs/base/common/performance.js';
// import * as bootstrap from './bootstrap.js';
// import * as bootstrapNode from './bootstrap-node.js';
// import * as bootstrapAmd from './bootstrap-amd.js';
// ESM-uncomment-end
performance.mark('code/fork/start');
// Crash reporter // Crash reporter
configureCrashReporter(); configureCrashReporter();
@@ -41,7 +50,7 @@ if (process.env['VSCODE_PARENT_PID']) {
} }
// Load AMD entry point // Load AMD entry point
require('./bootstrap-amd').load(process.env['VSCODE_AMD_ENTRYPOINT']); bootstrapAmd.load(process.env['VSCODE_AMD_ENTRYPOINT']);
//#region Helpers //#region Helpers

16
src/bootstrap-meta.js vendored
View File

@@ -10,6 +10,13 @@
* @import { IProductConfiguration } from './vs/base/common/product' * @import { IProductConfiguration } from './vs/base/common/product'
*/ */
// ESM-uncomment-begin
// import { createRequire } from 'node:module';
//
// const require = createRequire(import.meta.url);
// const module = { exports: {} };
// ESM-uncomment-end
/** @type Partial<IProductConfiguration> & { BUILD_INSERT_PRODUCT_CONFIGURATION?: string } */ /** @type Partial<IProductConfiguration> & { BUILD_INSERT_PRODUCT_CONFIGURATION?: string } */
let product = { BUILD_INSERT_PRODUCT_CONFIGURATION: 'BUILD_INSERT_PRODUCT_CONFIGURATION' }; // DO NOT MODIFY, PATCHED DURING BUILD let product = { BUILD_INSERT_PRODUCT_CONFIGURATION: 'BUILD_INSERT_PRODUCT_CONFIGURATION' }; // DO NOT MODIFY, PATCHED DURING BUILD
if (product['BUILD_INSERT_PRODUCT_CONFIGURATION']) { if (product['BUILD_INSERT_PRODUCT_CONFIGURATION']) {
@@ -24,5 +31,10 @@ if (pkg['BUILD_INSERT_PACKAGE_CONFIGURATION']) {
pkg = require('../package.json'); // Running out of sources pkg = require('../package.json'); // Running out of sources
} }
exports.product = product; module.exports.product = product;
exports.pkg = pkg; module.exports.pkg = pkg;
// ESM-uncomment-begin
// export const product = module.exports.product;
// export const pkg = module.exports.pkg;
// ESM-uncomment-end

46
src/bootstrap-node.js vendored
View File

@@ -6,12 +6,28 @@
//@ts-check //@ts-check
'use strict'; 'use strict';
// ESM-comment-begin
const path = require('path');
const fs = require('fs');
const isESM = false;
// ESM-comment-end
// ESM-uncomment-begin
// import * as path from 'path';
// import * as fs from 'fs';
// import { fileURLToPath } from 'url';
// import { createRequire } from 'node:module';
//
// const require = createRequire(import.meta.url);
// const isESM = true;
// const module = { exports: {} };
// const __dirname = path.dirname(fileURLToPath(import.meta.url));
// ESM-uncomment-end
// Setup current working directory in all our node & electron processes // Setup current working directory in all our node & electron processes
// - Windows: call `process.chdir()` to always set application folder as cwd // - Windows: call `process.chdir()` to always set application folder as cwd
// - all OS: store the `process.cwd()` inside `VSCODE_CWD` for consistent lookups // - all OS: store the `process.cwd()` inside `VSCODE_CWD` for consistent lookups
function setupCurrentWorkingDirectory() { function setupCurrentWorkingDirectory() {
const path = require('path');
try { try {
// Store the `process.cwd()` inside `VSCODE_CWD` // Store the `process.cwd()` inside `VSCODE_CWD`
@@ -38,14 +54,18 @@ setupCurrentWorkingDirectory();
* *
* @param {string} injectPath * @param {string} injectPath
*/ */
exports.injectNodeModuleLookupPath = function (injectPath) { module.exports.injectNodeModuleLookupPath = function (injectPath) {
if (!injectPath) { if (!injectPath) {
throw new Error('Missing injectPath'); throw new Error('Missing injectPath');
} }
const Module = require('module'); const Module = require('node:module');
const path = require('path'); if (isESM) {
// register a loader hook
// ESM-uncomment-begin
// Module.register('./server-loader.mjs', { parentURL: import.meta.url, data: injectPath });
// ESM-uncomment-end
} else {
const nodeModulesPath = path.join(__dirname, '../node_modules'); const nodeModulesPath = path.join(__dirname, '../node_modules');
// @ts-ignore // @ts-ignore
@@ -65,9 +85,10 @@ exports.injectNodeModuleLookupPath = function (injectPath) {
return paths; return paths;
}; };
}
}; };
exports.removeGlobalNodeModuleLookupPaths = function () { module.exports.removeGlobalNodeModuleLookupPaths = function () {
const Module = require('module'); const Module = require('module');
// @ts-ignore // @ts-ignore
const globalPaths = Module.globalPaths; const globalPaths = Module.globalPaths;
@@ -95,10 +116,7 @@ exports.removeGlobalNodeModuleLookupPaths = function () {
* @param {Partial<import('./vs/base/common/product').IProductConfiguration>} product * @param {Partial<import('./vs/base/common/product').IProductConfiguration>} product
* @returns {{ portableDataPath: string; isPortable: boolean; }} * @returns {{ portableDataPath: string; isPortable: boolean; }}
*/ */
exports.configurePortable = function (product) { module.exports.configurePortable = function (product) {
const fs = require('fs');
const path = require('path');
const appRoot = path.dirname(__dirname); const appRoot = path.dirname(__dirname);
/** /**
@@ -158,3 +176,9 @@ exports.configurePortable = function (product) {
isPortable isPortable
}; };
}; };
// ESM-uncomment-begin
// export const injectNodeModuleLookupPath = module.exports.injectNodeModuleLookupPath;
// export const removeGlobalNodeModuleLookupPaths = module.exports.removeGlobalNodeModuleLookupPaths;
// export const configurePortable = module.exports.configurePortable;
// ESM-uncomment-end

View File

@@ -10,12 +10,20 @@
/** /**
* @import { ISandboxConfiguration } from './vs/base/parts/sandbox/common/sandboxTypes' * @import { ISandboxConfiguration } from './vs/base/parts/sandbox/common/sandboxTypes'
* @typedef {any} LoaderConfig
*/ */
/* eslint-disable no-restricted-globals */ /* eslint-disable no-restricted-globals, */
// ESM-comment-begin
const isESM = false;
// ESM-comment-end
// ESM-uncomment-begin
// const isESM = true;
// ESM-uncomment-end
// Simple module style to support node.js and browser environments // Simple module style to support node.js and browser environments
(function (globalThis, factory) { (function (factory) {
// Node.js // Node.js
if (typeof exports === 'object') { if (typeof exports === 'object') {
@@ -27,7 +35,7 @@
// @ts-ignore // @ts-ignore
globalThis.MonacoBootstrapWindow = factory(); globalThis.MonacoBootstrapWindow = factory();
} }
}(this, function () { }(function () {
const bootstrapLib = bootstrap(); const bootstrapLib = bootstrap();
const preloadGlobals = sandboxGlobals(); const preloadGlobals = sandboxGlobals();
const safeProcess = preloadGlobals.process; const safeProcess = preloadGlobals.process;
@@ -96,7 +104,79 @@
window['MonacoEnvironment'] = {}; window['MonacoEnvironment'] = {};
/** @type {any} */ if (isESM) {
// Signal before require()
if (typeof options?.beforeRequire === 'function') {
options.beforeRequire(configuration);
}
const fileRoot = `${configuration.appRoot}/out`;
globalThis._VSCODE_FILE_ROOT = fileRoot;
// DEV ---------------------------------------------------------------------------------------
// DEV: This is for development and enables loading CSS via import-statements via import-maps.
// DEV: For each CSS modules that we have we defined an entry in the import map that maps to
// DEV: a blob URL that loads the CSS via a dynamic @import-rule.
// DEV ---------------------------------------------------------------------------------------
if (configuration.cssModules) {
performance.mark('code/willAddCssLoader');
const style = document.createElement('style');
style.type = 'text/css';
style.media = 'screen';
style.id = 'vscode-css-loading';
document.head.appendChild(style);
globalThis._VSCODE_CSS_LOAD = function (url) {
style.textContent += `@import url(${url});\n`;
};
const baseUrl = new URL(`vscode-file://vscode-app${fileRoot}/`);
/**
* @type { { imports: Record<string, string> }}
*/
const importMap = { imports: {} };
for (const cssModule of configuration.cssModules) {
const cssUrl = new URL(cssModule, baseUrl).href;
const jsSrc = `globalThis._VSCODE_CSS_LOAD('${cssUrl}');\n`;
const blob = new Blob([jsSrc], { type: 'application/javascript' });
importMap.imports[cssUrl] = URL.createObjectURL(blob);
}
const ttp = window.trustedTypes?.createPolicy('vscode-bootstrapImportMap', { createScript(value) { return value; }, });
const importMapSrc = JSON.stringify(importMap, undefined, 2);
const importMapScript = document.createElement('script');
importMapScript.type = 'importmap';
importMapScript.setAttribute('nonce', '0c6a828f1297');
// @ts-ignore
importMapScript.textContent = ttp?.createScript(importMapSrc) ?? importMapSrc;
document.head.appendChild(importMapScript);
performance.mark('code/didAddCssLoader');
}
const result = Promise.all(modulePaths.map(modulePath => {
if (modulePath.includes('vs/css!')) {
// ESM/CSS when seeing the old `vs/css!` prefix we use that as a signal to
// load CSS via a <link> tag
const cssModule = modulePath.replace('vs/css!', '');
const link = document.createElement('link');
link.rel = 'stylesheet';
link.href = `${configuration.appRoot}/out/${cssModule}.css`;
document.head.appendChild(link);
return Promise.resolve();
} else {
// ESM/JS module loading
return import(`${configuration.appRoot}/out/${modulePath}.js`);
}
}));
result.then((res) => invokeResult(res[0]), onUnexpectedError);
} else {
/** @type {LoaderConfig} */
const loaderConfig = { const loaderConfig = {
baseUrl: `${bootstrapLib.fileUriFromPath(configuration.appRoot, { isWindows: safeProcess.platform === 'win32', scheme: 'vscode-file', fallbackAuthority: 'vscode-app' })}/out`, baseUrl: `${bootstrapLib.fileUriFromPath(configuration.appRoot, { isWindows: safeProcess.platform === 'win32', scheme: 'vscode-file', fallbackAuthority: 'vscode-app' })}/out`,
preferScriptTags: true preferScriptTags: true
@@ -148,7 +228,13 @@
} }
// Actually require the main module as specified // Actually require the main module as specified
require(modulePaths, async firstModule => { require(modulePaths, invokeResult, onUnexpectedError);
}
/**
* @param {any} firstModule
*/
async function invokeResult(firstModule) {
try { try {
// Callback only after process environment is resolved // Callback only after process environment is resolved
@@ -163,7 +249,7 @@
} catch (error) { } catch (error) {
onUnexpectedError(error, enableDeveloperKeybindings); onUnexpectedError(error, enableDeveloperKeybindings);
} }
}, onUnexpectedError); }
} }
/** /**

24
src/bootstrap.js vendored
View File

@@ -6,11 +6,24 @@
//@ts-check //@ts-check
'use strict'; 'use strict';
// TODO@bpasero this file can no longer be used from a non-node.js context and thus should
// move into bootstrap-node.js and remaining usages (if any) in browser context be replaced.
// ESM-uncomment-begin
// import * as path from 'path';
// import { createRequire } from 'node:module';
// import { fileURLToPath } from 'url';
//
// const require = createRequire(import.meta.url);
// const module = { exports: {} };
// const __dirname = path.dirname(fileURLToPath(import.meta.url));
// ESM-uncomment-end
// Simple module style to support node.js and browser environments // Simple module style to support node.js and browser environments
(function (globalThis, factory) { (function (factory) {
// Node.js // Node.js
if (typeof exports === 'object') { if (typeof module === 'object' && typeof module.exports === 'object') {
module.exports = factory(); module.exports = factory();
} }
@@ -19,7 +32,7 @@
// @ts-ignore // @ts-ignore
globalThis.MonacoBootstrap = factory(); globalThis.MonacoBootstrap = factory();
} }
}(this, function () { }(function () {
const Module = typeof require === 'function' ? require('module') : undefined; const Module = typeof require === 'function' ? require('module') : undefined;
const path = typeof require === 'function' ? require('path') : undefined; const path = typeof require === 'function' ? require('path') : undefined;
@@ -121,3 +134,8 @@
fileUriFromPath fileUriFromPath
}; };
})); }));
// ESM-uncomment-begin
// export const enableASARSupport = module.exports.enableASARSupport;
// export const fileUriFromPath = module.exports.fileUriFromPath;
// ESM-uncomment-end

View File

@@ -6,19 +6,32 @@
//@ts-check //@ts-check
'use strict'; 'use strict';
// Delete `VSCODE_CWD` very early even before // ESM-comment-begin
// importing bootstrap files. We have seen const bootstrap = require('./bootstrap');
const bootstrapNode = require('./bootstrap-node');
const bootstrapAmd = require('./bootstrap-amd');
const { resolveNLSConfiguration } = require('./vs/base/node/nls');
const product = require('./bootstrap-meta').product;
// ESM-comment-end
// ESM-uncomment-begin
// import * as path from 'path';
// import { fileURLToPath } from 'url';
// import * as bootstrap from './bootstrap.js';
// import * as bootstrapNode from './bootstrap-node.js';
// import * as bootstrapAmd from './bootstrap-amd.js';
// import { resolveNLSConfiguration } from './vs/base/node/nls.js';
// import { product } from './bootstrap-meta.js';
//
// const __dirname = path.dirname(fileURLToPath(import.meta.url));
// ESM-uncomment-end
// Delete `VSCODE_CWD` very early. We have seen
// reports where `code .` would use the wrong // reports where `code .` would use the wrong
// current working directory due to our variable // current working directory due to our variable
// somehow escaping to the parent shell // somehow escaping to the parent shell
// (https://github.com/microsoft/vscode/issues/126399) // (https://github.com/microsoft/vscode/issues/126399)
delete process.env['VSCODE_CWD']; delete process.env['VSCODE_CWD'];
const bootstrap = require('./bootstrap');
const bootstrapNode = require('./bootstrap-node');
const product = require('./bootstrap-meta').product;
const { resolveNLSConfiguration } = require('./vs/base/node/nls');
async function start() { async function start() {
// NLS // NLS
@@ -36,7 +49,7 @@ async function start() {
process.env['VSCODE_CLI'] = '1'; process.env['VSCODE_CLI'] = '1';
// Load CLI through AMD loader // Load CLI through AMD loader
require('./bootstrap-amd').load('vs/code/node/cli'); bootstrapAmd.load('vs/code/node/cli');
} }
start(); start();

View File

@@ -11,19 +11,43 @@
* @import { NativeParsedArgs } from './vs/platform/environment/common/argv' * @import { NativeParsedArgs } from './vs/platform/environment/common/argv'
*/ */
const perf = require('./vs/base/common/performance'); // ESM-comment-begin
perf.mark('code/didStartMain');
const path = require('path'); const path = require('path');
const fs = require('original-fs'); const fs = require('original-fs');
const os = require('os'); const os = require('os');
const minimist = require('minimist');
const bootstrap = require('./bootstrap'); const bootstrap = require('./bootstrap');
const bootstrapNode = require('./bootstrap-node'); const bootstrapNode = require('./bootstrap-node');
const { getUserDataPath } = require('./vs/platform/environment/node/userDataPath'); const bootstrapAmd = require('./bootstrap-amd');
const { getUserDataPath } = require(`./vs/platform/environment/node/userDataPath`);
const { parse } = require('./vs/base/common/jsonc'); const { parse } = require('./vs/base/common/jsonc');
const perf = require('./vs/base/common/performance');
const { resolveNLSConfiguration } = require('./vs/base/node/nls');
const { getUNCHost, addUNCHostToAllowlist } = require('./vs/base/node/unc'); const { getUNCHost, addUNCHostToAllowlist } = require('./vs/base/node/unc');
const product = require('./bootstrap-meta').product; const product = require('./bootstrap-meta').product;
const { app, protocol, crashReporter, Menu } = require('electron'); const { app, protocol, crashReporter, Menu, contentTracing } = require('electron');
// ESM-comment-end
// ESM-uncomment-begin
// import * as path from 'path';
// import * as fs from 'original-fs';
// import * as os from 'os';
// import { fileURLToPath } from 'url';
// import { app, protocol, crashReporter, Menu, contentTracing } from 'electron';
// import minimist from 'minimist';
// import * as bootstrap from './bootstrap.js';
// import * as bootstrapNode from './bootstrap-node.js';
// import * as bootstrapAmd from './bootstrap-amd.js';
// import { product } from './bootstrap-meta.js';
// import { parse } from './vs/base/common/jsonc.js';
// import { getUserDataPath } from './vs/platform/environment/node/userDataPath.js';
// import * as perf from './vs/base/common/performance.js';
// import { resolveNLSConfiguration } from './vs/base/node/nls.js';
// import { getUNCHost, addUNCHostToAllowlist } from './vs/base/node/unc.js';
//
// const __dirname = path.dirname(fileURLToPath(import.meta.url));
// ESM-uncomment-end
perf.mark('code/didStartMain');
// Enable portable support // Enable portable support
const portable = bootstrapNode.configurePortable(product); const portable = bootstrapNode.configurePortable(product);
@@ -121,7 +145,6 @@ let nlsConfigurationPromise = undefined;
const osLocale = processZhLocale((app.getPreferredSystemLanguages()?.[0] ?? 'en').toLowerCase()); const osLocale = processZhLocale((app.getPreferredSystemLanguages()?.[0] ?? 'en').toLowerCase());
const userLocale = getUserDefinedLocale(argvConfig); const userLocale = getUserDefinedLocale(argvConfig);
if (userLocale) { if (userLocale) {
const { resolveNLSConfiguration } = require('./vs/base/node/nls');
nlsConfigurationPromise = resolveNLSConfiguration({ nlsConfigurationPromise = resolveNLSConfiguration({
userLocale, userLocale,
osLocale, osLocale,
@@ -147,8 +170,6 @@ if (process.platform === 'win32' || process.platform === 'linux') {
// Load our code once ready // Load our code once ready
app.once('ready', function () { app.once('ready', function () {
if (args['trace']) { if (args['trace']) {
const contentTracing = require('electron').contentTracing;
const traceOptions = { const traceOptions = {
categoryFilter: args['trace-category-filter'] || '*', categoryFilter: args['trace-category-filter'] || '*',
traceOptions: args['trace-options'] || 'record-until-full,enable-sampling' traceOptions: args['trace-options'] || 'record-until-full,enable-sampling'
@@ -187,7 +208,7 @@ function startup(codeCachePath, nlsConfig) {
// Load main in AMD // Load main in AMD
perf.mark('code/willLoadMainBundle'); perf.mark('code/willLoadMainBundle');
require('./bootstrap-amd').load('vs/code/electron-main/main', () => { bootstrapAmd.load('vs/code/electron-main/main', () => {
perf.mark('code/didLoadMainBundle'); perf.mark('code/didLoadMainBundle');
}); });
} }
@@ -495,8 +516,6 @@ function getJSFlags(cliArgs) {
* @returns {NativeParsedArgs} * @returns {NativeParsedArgs}
*/ */
function parseCLIArgs() { function parseCLIArgs() {
const minimist = require('minimist');
return minimist(process.argv, { return minimist(process.argv, {
string: [ string: [
'user-data-dir', 'user-data-dir',
@@ -665,7 +684,6 @@ async function resolveNlsConfiguration() {
// See above the comment about the loader and case sensitiveness // See above the comment about the loader and case sensitiveness
userLocale = processZhLocale(userLocale.toLowerCase()); userLocale = processZhLocale(userLocale.toLowerCase());
const { resolveNLSConfiguration } = require('./vs/base/node/nls');
return resolveNLSConfiguration({ return resolveNLSConfiguration({
userLocale, userLocale,
osLocale, osLocale,

View File

@@ -6,9 +6,23 @@
// @ts-check // @ts-check
'use strict'; 'use strict';
// ESM-comment-begin
const path = require('path'); const path = require('path');
const product = require('./bootstrap-meta').product; const bootstrapNode = require('./bootstrap-node');
const bootstrapAmd = require('./bootstrap-amd');
const { resolveNLSConfiguration } = require('./vs/base/node/nls'); const { resolveNLSConfiguration } = require('./vs/base/node/nls');
const product = require('./bootstrap-meta').product;
// ESM-comment-end
// ESM-uncomment-begin
// import * as path from 'path';
// import { fileURLToPath } from 'url';
// import * as bootstrapNode from './bootstrap-node.js';
// import * as bootstrapAmd from './bootstrap-amd.js';
// import { resolveNLSConfiguration } from './vs/base/node/nls.js';
// import { product } from './bootstrap-meta.js';
//
// const __dirname = path.dirname(fileURLToPath(import.meta.url));
// ESM-uncomment-end
async function start() { async function start() {
@@ -23,11 +37,11 @@ async function start() {
// When running out of sources, we need to load node modules from remote/node_modules, // When running out of sources, we need to load node modules from remote/node_modules,
// which are compiled against nodejs, not electron // which are compiled against nodejs, not electron
process.env['VSCODE_INJECT_NODE_MODULE_LOOKUP_PATH'] = process.env['VSCODE_INJECT_NODE_MODULE_LOOKUP_PATH'] || path.join(__dirname, '..', 'remote', 'node_modules'); process.env['VSCODE_INJECT_NODE_MODULE_LOOKUP_PATH'] = process.env['VSCODE_INJECT_NODE_MODULE_LOOKUP_PATH'] || path.join(__dirname, '..', 'remote', 'node_modules');
require('./bootstrap-node').injectNodeModuleLookupPath(process.env['VSCODE_INJECT_NODE_MODULE_LOOKUP_PATH']); bootstrapNode.injectNodeModuleLookupPath(process.env['VSCODE_INJECT_NODE_MODULE_LOOKUP_PATH']);
} else { } else {
delete process.env['VSCODE_INJECT_NODE_MODULE_LOOKUP_PATH']; delete process.env['VSCODE_INJECT_NODE_MODULE_LOOKUP_PATH'];
} }
require('./bootstrap-amd').load('vs/server/node/server.cli'); bootstrapAmd.load('vs/server/node/server.cli');
} }
start(); start();

View File

@@ -8,25 +8,46 @@
/** /**
* @import { INLSConfiguration } from './vs/nls' * @import { INLSConfiguration } from './vs/nls'
*/
/**
* @import { IServerAPI } from './vs/server/node/remoteExtensionHostAgentServer' * @import { IServerAPI } from './vs/server/node/remoteExtensionHostAgentServer'
*/ */
const perf = require('./vs/base/common/performance'); // ESM-comment-begin
const performance = require('perf_hooks').performance; const path = require('path');
const product = require('./bootstrap-meta').product;
const readline = require('readline');
const http = require('http'); const http = require('http');
const os = require('os');
const readline = require('readline');
const performance = require('perf_hooks').performance;
const bootstrapNode = require('./bootstrap-node');
const bootstrapAmd = require('./bootstrap-amd');
const { resolveNLSConfiguration } = require('./vs/base/node/nls'); const { resolveNLSConfiguration } = require('./vs/base/node/nls');
const product = require('./bootstrap-meta').product;
const perf = require(`./vs/base/common/performance`);
const minimist = require('minimist');
// ESM-comment-end
// ESM-uncomment-begin
// import * as path from 'path';
// import * as http from 'http';
// import * as os from 'os';
// import * as readline from 'readline';
// import { performance }from 'perf_hooks';
// import { fileURLToPath } from 'url';
// import { createRequire } from 'node:module';
// import * as bootstrapNode from './bootstrap-node.js';
// import * as bootstrapAmd from './bootstrap-amd.js';
// import { resolveNLSConfiguration } from './vs/base/node/nls.js';
// import { product } from './bootstrap-meta.js';
// import * as perf from './vs/base/common/performance.js';
// import minimist from 'minimist';
//
// const require = createRequire(import.meta.url);
// const __dirname = path.dirname(fileURLToPath(import.meta.url));
// ESM-uncomment-end
perf.mark('code/server/start'); perf.mark('code/server/start');
// @ts-ignore // @ts-ignore
global.vscodeServerStartTime = performance.now(); global.vscodeServerStartTime = performance.now();
async function start() { async function start() {
const minimist = require('minimist');
// Do a quick parse to determine if a server or the cli needs to be started // Do a quick parse to determine if a server or the cli needs to be started
const parsedArgs = minimist(process.argv.slice(2), { const parsedArgs = minimist(process.argv.slice(2), {
@@ -73,9 +94,6 @@ async function start() {
return _remoteExtensionHostAgentServerPromise; return _remoteExtensionHostAgentServerPromise;
}; };
const http = require('http');
const os = require('os');
if (Array.isArray(product.serverLicense) && product.serverLicense.length) { if (Array.isArray(product.serverLicense) && product.serverLicense.length) {
console.log(product.serverLicense.join('\n')); console.log(product.serverLicense.join('\n'));
if (product.serverLicensePrompt && parsedArgs['accept-server-license-terms'] !== true) { if (product.serverLicensePrompt && parsedArgs['accept-server-license-terms'] !== true) {
@@ -263,8 +281,6 @@ async function findFreePort(host, start, end) {
*/ */
function loadCode(nlsConfiguration) { function loadCode(nlsConfiguration) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const path = require('path');
delete process.env['ELECTRON_RUN_AS_NODE']; // Keep bootstrap-amd.js from redefining 'fs'. delete process.env['ELECTRON_RUN_AS_NODE']; // Keep bootstrap-amd.js from redefining 'fs'.
/** @type {INLSConfiguration} */ /** @type {INLSConfiguration} */
@@ -280,11 +296,11 @@ function loadCode(nlsConfiguration) {
// When running out of sources, we need to load node modules from remote/node_modules, // When running out of sources, we need to load node modules from remote/node_modules,
// which are compiled against nodejs, not electron // which are compiled against nodejs, not electron
process.env['VSCODE_INJECT_NODE_MODULE_LOOKUP_PATH'] = process.env['VSCODE_INJECT_NODE_MODULE_LOOKUP_PATH'] || path.join(__dirname, '..', 'remote', 'node_modules'); process.env['VSCODE_INJECT_NODE_MODULE_LOOKUP_PATH'] = process.env['VSCODE_INJECT_NODE_MODULE_LOOKUP_PATH'] || path.join(__dirname, '..', 'remote', 'node_modules');
require('./bootstrap-node').injectNodeModuleLookupPath(process.env['VSCODE_INJECT_NODE_MODULE_LOOKUP_PATH']); bootstrapNode.injectNodeModuleLookupPath(process.env['VSCODE_INJECT_NODE_MODULE_LOOKUP_PATH']);
} else { } else {
delete process.env['VSCODE_INJECT_NODE_MODULE_LOOKUP_PATH']; delete process.env['VSCODE_INJECT_NODE_MODULE_LOOKUP_PATH'];
} }
require('./bootstrap-amd').load('vs/server/node/server.main', resolve, reject); bootstrapAmd.load('vs/server/node/server.main', resolve, reject);
}); });
} }

View File

@@ -39,5 +39,8 @@
], ],
"ban-element-insertadjacenthtml": [ "ban-element-insertadjacenthtml": [
"**/*.ts" "**/*.ts"
],
"ban-script-content-assignments": [
"bootstrap-window.js"
] ]
} }

View File

@@ -7,6 +7,17 @@
declare global { declare global {
/**
* Holds the file root for resources.
*/
var _VSCODE_FILE_ROOT: string;
/**
* CSS loader that's available during development time.
* DO NOT call directly, instead just import css modules, like `import 'some.css'`
*/
var _VSCODE_CSS_LOAD: (module: string) => void;
/** /**
* @deprecated You MUST use `IProductService` whenever possible. * @deprecated You MUST use `IProductService` whenever possible.
*/ */

View File

@@ -8,8 +8,13 @@
//@ts-check //@ts-check
'use strict'; 'use strict';
// ESM-uncomment-begin
// const module = { exports: {} };
// ESM-uncomment-end
(function () { (function () {
function factory(path, os, productName, cwd) {
function factory() {
// First group matches a double quoted string // First group matches a double quoted string
// Second group matches a single quoted string // Second group matches a single quoted string
// Third group matches a multi line comment // Third group matches a multi line comment
@@ -77,3 +82,8 @@
console.trace('jsonc defined in UNKNOWN context (neither requirejs or commonjs)'); console.trace('jsonc defined in UNKNOWN context (neither requirejs or commonjs)');
} }
})(); })();
// ESM-uncomment-begin
// export const stripComments = module.exports.stripComments;
// export const parse = module.exports.parse;
// ESM-uncomment-end

View File

@@ -6,6 +6,10 @@
//@ts-check //@ts-check
'use strict'; 'use strict';
// ESM-uncomment-begin
// const module = { exports: {} };
// ESM-uncomment-end
(function () { (function () {
/** /**
@@ -124,3 +128,8 @@
} }
})(); })();
// ESM-uncomment-begin
// export const mark = module.exports.mark;
// export const getMarks = module.exports.getMarks;
// ESM-uncomment-end

View File

@@ -3,9 +3,14 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
// ESM-comment-begin
export as namespace semver; export as namespace semver;
export = semver; export = semver;
// ESM-comment-end
// ESM-uncomment-begin
// export * from 'semver'
// ESM-uncomment-end
declare namespace semver { declare namespace semver {

File diff suppressed because one or more lines are too long

View File

@@ -13,6 +13,14 @@
* @import { IResolveNLSConfigurationContext } from './nls' * @import { IResolveNLSConfigurationContext } from './nls'
*/ */
// ESM-uncomment-begin
// import * as path from 'path';
// import * as fs from 'fs';
// import * as perf from '../common/performance.js';
//
// const module = { exports: {} };
// ESM-uncomment-end
(function () { (function () {
/** /**
@@ -249,11 +257,17 @@
define(['path', 'fs', 'vs/base/common/performance'], function (/** @type {typeof import('path')} */ path, /** @type {typeof import('fs')} */ fs, /** @type {typeof import('../common/performance')} */ perf) { return factory(path, fs, perf); }); define(['path', 'fs', 'vs/base/common/performance'], function (/** @type {typeof import('path')} */ path, /** @type {typeof import('fs')} */ fs, /** @type {typeof import('../common/performance')} */ perf) { return factory(path, fs, perf); });
} else if (typeof module === 'object' && typeof module.exports === 'object') { } else if (typeof module === 'object' && typeof module.exports === 'object') {
// commonjs // commonjs
// ESM-comment-begin
const path = require('path'); const path = require('path');
const fs = require('fs'); const fs = require('fs');
const perf = require('../common/performance'); const perf = require('../common/performance');
// ESM-comment-end
module.exports = factory(path, fs, perf); module.exports = factory(path, fs, perf);
} else { } else {
throw new Error('vs/base/node/nls defined in UNKNOWN context (neither requirejs or commonjs)'); throw new Error('vs/base/node/nls defined in UNKNOWN context (neither requirejs or commonjs)');
} }
})(); })();
// ESM-uncomment-begin
// export const resolveNLSConfiguration = module.exports.resolveNLSConfiguration;
// ESM-uncomment-end

View File

@@ -8,6 +8,10 @@
//@ts-check //@ts-check
'use strict'; 'use strict';
// ESM-uncomment-begin
// const module = { exports: {} };
// ESM-uncomment-end
(function () { (function () {
function factory() { function factory() {
@@ -148,3 +152,11 @@
console.trace('vs/base/node/unc defined in UNKNOWN context (neither requirejs or commonjs)'); console.trace('vs/base/node/unc defined in UNKNOWN context (neither requirejs or commonjs)');
} }
})(); })();
// ESM-uncomment-begin
// export const getUNCHost = module.exports.getUNCHost;
// export const getUNCHostAllowlist = module.exports.getUNCHostAllowlist;
// export const addUNCHostToAllowlist = module.exports.addUNCHostToAllowlist;
// export const disableUNCAccessRestrictions = module.exports.disableUNCAccessRestrictions;
// export const isUNCAccessRestrictionsDisabled = module.exports.isUNCAccessRestrictionsDisabled;
// ESM-uncomment-end

View File

@@ -70,4 +70,9 @@ export interface ISandboxConfiguration {
*/ */
language: string | undefined; language: string | undefined;
}; };
/**
* DEV time only! All css-modules that we have.
*/
cssModules?: string[];
} }

View File

@@ -309,8 +309,14 @@ export class SQLiteStorageDatabase implements IStorageDatabase {
private doConnect(path: string): Promise<IDatabaseConnection> { private doConnect(path: string): Promise<IDatabaseConnection> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
import('@vscode/sqlite3').then(sqlite3 => { import('@vscode/sqlite3').then(sqlite3 => {
// ESM-comment-begin
const ctor = (this.logger.isTracing ? sqlite3.verbose().Database : sqlite3.Database);
// ESM-comment-end
// ESM-uncomment-begin
// const ctor = (this.logger.isTracing ? sqlite3.default.verbose().Database : sqlite3.default.Database);
// ESM-uncomment-end
const connection: IDatabaseConnection = { const connection: IDatabaseConnection = {
db: new (this.logger.isTracing ? sqlite3.verbose().Database : sqlite3.Database)(path, (error: (Error & { code?: string }) | null) => { db: new ctor(path, (error: (Error & { code?: string }) | null) => {
if (error) { if (error) {
return (connection.db && error.code !== 'SQLITE_CANTOPEN' /* https://github.com/TryGhost/node-sqlite3/issues/1617 */) ? connection.db.close(() => reject(error)) : reject(error); return (connection.db && error.code !== 'SQLITE_CANTOPEN' /* https://github.com/TryGhost/node-sqlite3/issues/1617 */) ? connection.db.close(() => reject(error)) : reject(error);
} }

View File

@@ -4,8 +4,9 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
//@ts-check //@ts-check
'use strict';
(function () { (function () {
'use strict';
/** /**
* @import { ISandboxConfiguration } from '../../../base/parts/sandbox/common/sandboxTypes' * @import { ISandboxConfiguration } from '../../../base/parts/sandbox/common/sandboxTypes'

View File

@@ -6,8 +6,9 @@
/// <reference path="../../../../typings/require.d.ts" /> /// <reference path="../../../../typings/require.d.ts" />
//@ts-check //@ts-check
'use strict';
(function () { (function () {
'use strict';
/** /**
* @import {INativeWindowConfiguration} from '../../../platform/window/common/window' * @import {INativeWindowConfiguration} from '../../../platform/window/common/window'

View File

@@ -6,8 +6,16 @@
/// <reference path="../../../../typings/require.d.ts" /> /// <reference path="../../../../typings/require.d.ts" />
//@ts-check //@ts-check
'use strict';
// ESM-uncomment-begin
// import * as os from 'os';
// import * as path from 'path';
//
// const module = { exports: {} };
// ESM-uncomment-end
(function () { (function () {
'use strict';
/** /**
* @import { NativeParsedArgs } from '../../environment/common/argv' * @import { NativeParsedArgs } from '../../environment/common/argv'
@@ -117,11 +125,17 @@
return factory(path, os, process.cwd()); // amd return factory(path, os, process.cwd()); // amd
}); });
} else if (typeof module === 'object' && typeof module.exports === 'object') { } else if (typeof module === 'object' && typeof module.exports === 'object') {
// ESM-comment-begin
const path = require('path'); const path = require('path');
const os = require('os'); const os = require('os');
// ESM-comment-end
module.exports = factory(path, os, process.env['VSCODE_CWD'] || process.cwd()); // commonjs module.exports = factory(path, os, process.env['VSCODE_CWD'] || process.cwd()); // commonjs
} else { } else {
throw new Error('Unknown context'); throw new Error('Unknown context');
} }
}()); }());
// ESM-uncomment-begin
// export const getUserDataPath = module.exports.getUserDataPath;
// ESM-uncomment-end

View File

@@ -56,7 +56,12 @@ flakySuite('Native Modules (all platforms)', () => {
}); });
test('@vscode/sqlite3', async () => { test('@vscode/sqlite3', async () => {
// ESM-comment-begin
const sqlite3 = await import('@vscode/sqlite3'); const sqlite3 = await import('@vscode/sqlite3');
// ESM-comment-end
// ESM-uncomment-begin
// const { default: sqlite3 } = await import('@vscode/sqlite3');
// ESM-uncomment-end
assert.ok(typeof sqlite3.Database === 'function', testErrorMessage('@vscode/sqlite3')); assert.ok(typeof sqlite3.Database === 'function', testErrorMessage('@vscode/sqlite3'));
}); });

View File

@@ -44,7 +44,21 @@ export async function getProxyAgent(rawRequestURL: string, env: typeof process.e
rejectUnauthorized: isBoolean(options.strictSSL) ? options.strictSSL : true, rejectUnauthorized: isBoolean(options.strictSSL) ? options.strictSSL : true,
}; };
return requestURL.protocol === 'http:' if (requestURL.protocol === 'http:') {
? new (await import('http-proxy-agent')).HttpProxyAgent(proxyURL, opts) // ESM-comment-begin
: new (await import('https-proxy-agent')).HttpsProxyAgent(proxyURL, opts); const mod = await import('http-proxy-agent');
// ESM-comment-end
// ESM-uncomment-begin
// const mod = (await import('http-proxy-agent')).default;
// ESM-uncomment-end
return new mod.HttpProxyAgent(proxyURL, opts);
} else {
// ESM-comment-begin
const mod = await import('https-proxy-agent');
// ESM-comment-end
// ESM-uncomment-begin
// const mod = (await import('https-proxy-agent')).default;
// ESM-uncomment-end
return new mod.HttpsProxyAgent(proxyURL, opts);
}
} }

View File

@@ -15,7 +15,6 @@ import { RequestStore } from 'vs/platform/terminal/common/requestStore';
import { IProcessDataEvent, IProcessReadyEvent, IPtyService, IRawTerminalInstanceLayoutInfo, IReconnectConstants, IShellLaunchConfig, ITerminalInstanceLayoutInfoById, ITerminalLaunchError, ITerminalsLayoutInfo, ITerminalTabLayoutInfoById, TerminalIcon, IProcessProperty, TitleEventSource, ProcessPropertyType, IProcessPropertyMap, IFixedTerminalDimensions, IPersistentTerminalProcessLaunchConfig, ICrossVersionSerializedTerminalState, ISerializedTerminalState, ITerminalProcessOptions, IPtyHostLatencyMeasurement } from 'vs/platform/terminal/common/terminal'; import { IProcessDataEvent, IProcessReadyEvent, IPtyService, IRawTerminalInstanceLayoutInfo, IReconnectConstants, IShellLaunchConfig, ITerminalInstanceLayoutInfoById, ITerminalLaunchError, ITerminalsLayoutInfo, ITerminalTabLayoutInfoById, TerminalIcon, IProcessProperty, TitleEventSource, ProcessPropertyType, IProcessPropertyMap, IFixedTerminalDimensions, IPersistentTerminalProcessLaunchConfig, ICrossVersionSerializedTerminalState, ISerializedTerminalState, ITerminalProcessOptions, IPtyHostLatencyMeasurement } from 'vs/platform/terminal/common/terminal';
import { TerminalDataBufferer } from 'vs/platform/terminal/common/terminalDataBuffering'; import { TerminalDataBufferer } from 'vs/platform/terminal/common/terminalDataBuffering';
import { escapeNonWindowsPath } from 'vs/platform/terminal/common/terminalEnvironment'; import { escapeNonWindowsPath } from 'vs/platform/terminal/common/terminalEnvironment';
import { Terminal as XtermTerminal } from '@xterm/headless';
import type { ISerializeOptions, SerializeAddon as XtermSerializeAddon } from '@xterm/addon-serialize'; import type { ISerializeOptions, SerializeAddon as XtermSerializeAddon } from '@xterm/addon-serialize';
import type { Unicode11Addon as XtermUnicode11Addon } from '@xterm/addon-unicode11'; import type { Unicode11Addon as XtermUnicode11Addon } from '@xterm/addon-unicode11';
import { IGetTerminalLayoutInfoArgs, IProcessDetails, ISetTerminalLayoutInfoArgs, ITerminalTabLayoutInfoDto } from 'vs/platform/terminal/common/terminalProcess'; import { IGetTerminalLayoutInfoArgs, IProcessDetails, ISetTerminalLayoutInfoArgs, ITerminalTabLayoutInfoDto } from 'vs/platform/terminal/common/terminalProcess';
@@ -32,6 +31,14 @@ import { IProductService } from 'vs/platform/product/common/productService';
import { join } from 'path'; import { join } from 'path';
import { memoize } from 'vs/base/common/decorators'; import { memoize } from 'vs/base/common/decorators';
import * as performance from 'vs/base/common/performance'; import * as performance from 'vs/base/common/performance';
// ESM-comment-begin
import { Terminal as XtermTerminal } from '@xterm/headless';
// ESM-comment-end
// ESM-uncomment-begin
// import pkg from '@xterm/headless';
// type XtermTerminal = pkg.Terminal;
// const { Terminal: XtermTerminal } = pkg;
// ESM-uncomment-end
export function traceRpc(_target: any, key: string, descriptor: any) { export function traceRpc(_target: any, key: string, descriptor: any) {
if (typeof descriptor.value !== 'function') { if (typeof descriptor.value !== 'function') {

View File

@@ -3,11 +3,10 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as _fs from 'fs'; import * as fs from 'fs';
import * as _url from 'url'; import * as url from 'url';
import * as _cp from 'child_process'; import * as cp from 'child_process';
import * as _http from 'http'; import * as http from 'http';
import * as _os from 'os';
import { cwd } from 'vs/base/common/process'; import { cwd } from 'vs/base/common/process';
import { dirname, extname, resolve, join } from 'vs/base/common/path'; import { dirname, extname, resolve, join } from 'vs/base/common/path';
import { parseArgs, buildHelpMessage, buildVersionMessage, OPTIONS, OptionDescriptions, ErrorReporter } from 'vs/platform/environment/node/argv'; import { parseArgs, buildHelpMessage, buildVersionMessage, OPTIONS, OptionDescriptions, ErrorReporter } from 'vs/platform/environment/node/argv';
@@ -240,8 +239,8 @@ export async function main(desc: ProductDescription, args: string[]): Promise<vo
cmdLine.push('--update-extensions'); cmdLine.push('--update-extensions');
} }
const cp = _cp.fork(join(__dirname, '../../../server-main.js'), cmdLine, { stdio: 'inherit' }); const childProcess = cp.fork(join(__dirname, '../../../server-main.js'), cmdLine, { stdio: 'inherit' });
cp.on('error', err => console.log(err)); childProcess.on('error', err => console.log(err));
return; return;
} }
@@ -270,7 +269,7 @@ export async function main(desc: ProductDescription, args: string[]): Promise<vo
if (verbose) { if (verbose) {
console.log(`Invoking: cmd.exe /C ${cliCommand} ${newCommandline.join(' ')} in ${processCwd}`); console.log(`Invoking: cmd.exe /C ${cliCommand} ${newCommandline.join(' ')} in ${processCwd}`);
} }
_cp.spawn('cmd.exe', ['/C', cliCommand, ...newCommandline], { cp.spawn('cmd.exe', ['/C', cliCommand, ...newCommandline], {
stdio: 'inherit', stdio: 'inherit',
cwd: processCwd cwd: processCwd
}); });
@@ -285,11 +284,11 @@ export async function main(desc: ProductDescription, args: string[]): Promise<vo
if (verbose) { if (verbose) {
console.log(`Using pipes for output.`); console.log(`Using pipes for output.`);
} }
const cp = _cp.spawn(cliCommand, newCommandline, { cwd: cliCwd, env, stdio: ['inherit', 'pipe', 'pipe'] }); const childProcess = cp.spawn(cliCommand, newCommandline, { cwd: cliCwd, env, stdio: ['inherit', 'pipe', 'pipe'] });
cp.stdout.on('data', data => process.stdout.write(data)); childProcess.stdout.on('data', data => process.stdout.write(data));
cp.stderr.on('data', data => process.stderr.write(data)); childProcess.stderr.on('data', data => process.stderr.write(data));
} else { } else {
_cp.spawn(cliCommand, newCommandline, { cwd: cliCwd, env, stdio: 'inherit' }); cp.spawn(cliCommand, newCommandline, { cwd: cliCwd, env, stdio: 'inherit' });
} }
} }
} else { } else {
@@ -357,7 +356,7 @@ export async function main(desc: ProductDescription, args: string[]): Promise<vo
function runningInWSL2(): boolean { function runningInWSL2(): boolean {
if (!!process.env['WSL_DISTRO_NAME']) { if (!!process.env['WSL_DISTRO_NAME']) {
try { try {
return _cp.execSync('uname -r', { encoding: 'utf8' }).includes('-microsoft-'); return cp.execSync('uname -r', { encoding: 'utf8' }).includes('-microsoft-');
} catch (_e) { } catch (_e) {
// Ignore // Ignore
} }
@@ -366,7 +365,7 @@ function runningInWSL2(): boolean {
} }
async function waitForFileDeleted(path: string) { async function waitForFileDeleted(path: string) {
while (_fs.existsSync(path)) { while (fs.existsSync(path)) {
await new Promise(res => setTimeout(res, 1000)); await new Promise(res => setTimeout(res, 1000));
} }
} }
@@ -376,7 +375,7 @@ function openInBrowser(args: string[], verbose: boolean) {
for (const location of args) { for (const location of args) {
try { try {
if (/^(http|https|file):\/\//.test(location)) { if (/^(http|https|file):\/\//.test(location)) {
uris.push(_url.parse(location).href); uris.push(url.parse(location).href);
} else { } else {
uris.push(pathToURI(location).href); uris.push(pathToURI(location).href);
} }
@@ -406,7 +405,7 @@ function sendToPipe(args: PipeCommand, verbose: boolean): Promise<any> {
return; return;
} }
const opts: _http.RequestOptions = { const opts: http.RequestOptions = {
socketPath: cliPipe, socketPath: cliPipe,
path: '/', path: '/',
method: 'POST', method: 'POST',
@@ -416,7 +415,7 @@ function sendToPipe(args: PipeCommand, verbose: boolean): Promise<any> {
} }
}; };
const req = _http.request(opts, res => { const req = http.request(opts, res => {
if (res.headers['content-type'] !== 'application/json') { if (res.headers['content-type'] !== 'application/json') {
reject('Error in response: Invalid content type: Expected \'application/json\', is: ' + res.headers['content-type']); reject('Error in response: Invalid content type: Expected \'application/json\', is: ' + res.headers['content-type']);
return; return;
@@ -461,18 +460,18 @@ function fatal(message: string, err: any): void {
const preferredCwd = process.env.PWD || cwd(); // prefer process.env.PWD as it does not follow symlinks const preferredCwd = process.env.PWD || cwd(); // prefer process.env.PWD as it does not follow symlinks
function pathToURI(input: string): _url.URL { function pathToURI(input: string): url.URL {
input = input.trim(); input = input.trim();
input = resolve(preferredCwd, input); input = resolve(preferredCwd, input);
return _url.pathToFileURL(input); return url.pathToFileURL(input);
} }
function translatePath(input: string, mapFileUri: (input: string) => string, folderURIS: string[], fileURIS: string[]) { function translatePath(input: string, mapFileUri: (input: string) => string, folderURIS: string[], fileURIS: string[]) {
const url = pathToURI(input); const url = pathToURI(input);
const mappedUri = mapFileUri(url.href); const mappedUri = mapFileUri(url.href);
try { try {
const stat = _fs.lstatSync(_fs.realpathSync(input)); const stat = fs.lstatSync(fs.realpathSync(input));
if (stat.isFile()) { if (stat.isFile()) {
fileURIS.push(mappedUri); fileURIS.push(mappedUri);

View File

@@ -18,6 +18,10 @@ import { CLIServer } from 'vs/workbench/api/node/extHostCLIServer';
import { realpathSync } from 'vs/base/node/extpath'; import { realpathSync } from 'vs/base/node/extpath';
import { ExtHostConsoleForwarder } from 'vs/workbench/api/node/extHostConsoleForwarder'; import { ExtHostConsoleForwarder } from 'vs/workbench/api/node/extHostConsoleForwarder';
import { ExtHostDiskFileSystemProvider } from 'vs/workbench/api/node/extHostDiskFileSystemProvider'; import { ExtHostDiskFileSystemProvider } from 'vs/workbench/api/node/extHostDiskFileSystemProvider';
// ESM-uncomment-begin
// import { createRequire } from 'node:module';
// const require = createRequire(import.meta.url);
// ESM-uncomment-end
class NodeModuleRequireInterceptor extends RequireInterceptor { class NodeModuleRequireInterceptor extends RequireInterceptor {
@@ -109,7 +113,7 @@ export class ExtHostExtensionService extends AbstractExtHostExtensionService {
if (extensionId) { if (extensionId) {
performance.mark(`code/extHost/willLoadExtensionCode/${extensionId}`); performance.mark(`code/extHost/willLoadExtensionCode/${extensionId}`);
} }
r = require.__$__nodeRequire<T>(module.fsPath); r = <T>require.__$__nodeRequire(module.fsPath);
} finally { } finally {
if (extensionId) { if (extensionId) {
performance.mark(`code/extHost/didLoadExtensionCode/${extensionId}`); performance.mark(`code/extHost/didLoadExtensionCode/${extensionId}`);

View File

@@ -3,10 +3,12 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
// ESM-comment-begin
import * as http from 'http'; import * as http from 'http';
import * as https from 'https'; import * as https from 'https';
import * as tls from 'tls'; import * as tls from 'tls';
import * as net from 'net'; import * as net from 'net';
// ESM-comment-end
import { IExtHostWorkspaceProvider } from 'vs/workbench/api/common/extHostWorkspace'; import { IExtHostWorkspaceProvider } from 'vs/workbench/api/common/extHostWorkspace';
import { ExtHostConfigProvider } from 'vs/workbench/api/common/extHostConfiguration'; import { ExtHostConfigProvider } from 'vs/workbench/api/common/extHostConfiguration';
@@ -19,6 +21,15 @@ import { IExtensionDescription } from 'vs/platform/extensions/common/extensions'
import { LogLevel, createHttpPatch, createProxyResolver, createTlsPatch, ProxySupportSetting, ProxyAgentParams, createNetPatch, loadSystemCertificates } from '@vscode/proxy-agent'; import { LogLevel, createHttpPatch, createProxyResolver, createTlsPatch, ProxySupportSetting, ProxyAgentParams, createNetPatch, loadSystemCertificates } from '@vscode/proxy-agent';
import { AuthInfo } from 'vs/platform/request/common/request'; import { AuthInfo } from 'vs/platform/request/common/request';
// ESM-uncomment-begin
// import { createRequire } from 'node:module';
// const require = createRequire(import.meta.url);
// const http = require('http');
// const https = require('https');
// const tls = require('tls');
// const net = require('net');
// ESM-uncomment-end
const systemCertificatesV2Default = false; const systemCertificatesV2Default = false;
export function connectProxyResolver( export function connectProxyResolver(

View File

@@ -4,8 +4,9 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
//@ts-check //@ts-check
'use strict';
(function () { (function () {
'use strict';
/** /**
* @import { ISandboxConfiguration } from '../../../../base/parts/sandbox/common/sandboxTypes' * @import { ISandboxConfiguration } from '../../../../base/parts/sandbox/common/sandboxTypes'