esm - some 💄

This commit is contained in:
Benjamin Pasero
2024-09-27 11:36:53 +02:00
parent 7bf2f5e196
commit 293e725467
7 changed files with 15 additions and 15 deletions
-2
View File
@@ -3,8 +3,6 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
/* eslint-disable local/code-import-patterns */
// Delete `VSCODE_CWD` very early. We have seen
// reports where `code .` would use the wrong
// current working directory due to our variable
+1 -2
View File
@@ -36,16 +36,15 @@ if (process.env['ELECTRON_RUN_AS_NODE'] || process.versions['electron']) {
register(`data:text/javascript;base64,${Buffer.from(jsCode).toString('base64')}`, import.meta.url);
}
// Prepare globals that are needed for running
globalThis._VSCODE_PRODUCT_JSON = { ...product };
if (process.env['VSCODE_DEV']) {
// Patch product overrides when running out of sources
try {
const overrides = require('../product.overrides.json');
globalThis._VSCODE_PRODUCT_JSON = Object.assign(globalThis._VSCODE_PRODUCT_JSON, overrides);
} catch (error) { /* ignore */ }
}
globalThis._VSCODE_PACKAGE_JSON = { ...pkg };
globalThis._VSCODE_FILE_ROOT = __dirname;
//#region NLS helpers
+1 -1
View File
@@ -6,7 +6,7 @@
/* eslint-disable local/code-import-patterns */
import { createRequire } from 'node:module';
import { IProductConfiguration } from './vs/base/common/product.js';
import type { IProductConfiguration } from './vs/base/common/product.js';
const require = createRequire(import.meta.url);
+5 -3
View File
@@ -9,7 +9,7 @@ import * as path from 'path';
import * as fs from 'fs';
import { fileURLToPath } from 'url';
import { createRequire } from 'node:module';
import { IProductConfiguration } from './vs/base/common/product';
import type { IProductConfiguration } from './vs/base/common/product';
const require = createRequire(import.meta.url);
const __dirname = path.dirname(fileURLToPath(import.meta.url));
@@ -93,8 +93,10 @@ export function removeGlobalNodeJsModuleLookupPaths(): void {
while (commonSuffixLength < paths.length && paths[paths.length - 1 - commonSuffixLength] === globalPaths[globalPaths.length - 1 - commonSuffixLength]) {
commonSuffixLength++;
}
return paths.slice(0, paths.length - commonSuffixLength);
}
return paths;
};
}
@@ -105,7 +107,7 @@ export function removeGlobalNodeJsModuleLookupPaths(): void {
export function configurePortable(product: Partial<IProductConfiguration>): { portableDataPath: string; isPortable: boolean } {
const appRoot = path.dirname(__dirname);
function getApplicationPath() {
function getApplicationPath(): string {
if (process.env['VSCODE_DEV']) {
return appRoot;
}
@@ -117,7 +119,7 @@ export function configurePortable(product: Partial<IProductConfiguration>): { po
return path.dirname(path.dirname(appRoot));
}
function getPortableDataPath() {
function getPortableDataPath(): string {
if (process.env['VSCODE_PORTABLE']) {
return process.env['VSCODE_PORTABLE'];
}
+5 -5
View File
@@ -8,8 +8,8 @@
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 bootstrapESM from './bootstrap-esm.js';
import { configurePortable } from './bootstrap-node.js';
import { load } from './bootstrap-esm.js';
import { fileURLToPath } from 'url';
import { app, protocol, crashReporter, Menu, contentTracing } from 'electron';
import minimist from 'minimist';
@@ -27,7 +27,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
perf.mark('code/didStartMain');
// Enable portable support
const portable = bootstrapNode.configurePortable(product);
const portable = configurePortable(product);
const args = parseCLIArgs();
// Configure static command line arguments
@@ -176,7 +176,7 @@ function startup(codeCachePath: string | undefined, nlsConfig: INLSConfiguration
process.env['VSCODE_CODE_CACHE_PATH'] = codeCachePath || '';
perf.mark('code/willLoadMainBundle');
bootstrapESM.load('vs/code/electron-main/main', () => {
load('vs/code/electron-main/main', () => {
perf.mark('code/didLoadMainBundle');
});
}
@@ -232,7 +232,7 @@ function configureCommandlineSwitchesSync(cliArgs: NativeParsedArgs) {
} else {
app.commandLine.appendSwitch(argvKey);
}
} else if (typeof argvValue === 'string') {
} else if (typeof argvValue === 'string' && argvValue) {
if (argvKey === 'password-store') {
// Password store
// TODO@TylerLeonhardt: Remove this migration in 3 months
+1 -1
View File
@@ -257,7 +257,7 @@ function loadCode(nlsConfiguration: INLSConfiguration): Promise<typeof import('.
});
}
function hasStdinWithoutTty() {
function hasStdinWithoutTty(): boolean {
try {
return !process.stdin.isTTY; // Via https://twitter.com/MylesBorins/status/782009479382626304
} catch (error) {
+2 -1
View File
@@ -6,7 +6,7 @@
import * as path from 'path';
import * as fs from 'fs';
import * as perf from '../common/performance.js';
import { ILanguagePacks, INLSConfiguration } from '../../nls.js';
import type { ILanguagePacks, INLSConfiguration } from '../../nls.js';
export interface IResolveNLSConfigurationContext {
@@ -226,6 +226,7 @@ async function exists(path: string): Promise<boolean> {
function touch(path: string): Promise<void> {
const date = new Date();
return fs.promises.utimes(path, date, date);
}