mirror of
https://github.com/Microsoft/vscode
synced 2024-10-02 09:18:59 +00:00
don't use __$__nodeRequire
to fetch product configuration
This commit is contained in:
parent
2d6ad4be88
commit
8dd8d214d8
4
src/bootstrap-fork.js
vendored
4
src/bootstrap-fork.js
vendored
|
@ -47,11 +47,13 @@ globalThis._VSCODE_NODE_MODULES = new Proxy(Object.create(null), {
|
|||
}
|
||||
});
|
||||
|
||||
// VSCODE_GLOBALS: package/product.json
|
||||
globalThis._VSCODE_PRODUCT_JSON = require('../product.json');
|
||||
globalThis._VSCODE_PACKAGE_JSON = require('../package.json');
|
||||
|
||||
// Load AMD entry point
|
||||
require('./bootstrap-amd').load(process.env['VSCODE_AMD_ENTRYPOINT']);
|
||||
|
||||
|
||||
//#region Helpers
|
||||
|
||||
function pipeLoggingToParent() {
|
||||
|
|
4
src/bootstrap-window.js
vendored
4
src/bootstrap-window.js
vendored
|
@ -122,6 +122,10 @@
|
|||
}
|
||||
});
|
||||
|
||||
// VSCODE_GLOBALS: package/product.json
|
||||
globalThis._VSCODE_PRODUCT_JSON = (require.__$__nodeRequire ?? require)(configuration.appRoot + '/product.json');
|
||||
globalThis._VSCODE_PACKAGE_JSON = (require.__$__nodeRequire ?? require)(configuration.appRoot + '/package.json');
|
||||
|
||||
const loaderConfig = {
|
||||
baseUrl: `${bootstrapLib.fileUriFromPath(configuration.appRoot, { isWindows: safeProcess.platform === 'win32', scheme: 'vscode-file', fallbackAuthority: 'vscode-app' })}/out`,
|
||||
'vs/nls': nlsConfig,
|
||||
|
|
|
@ -151,6 +151,10 @@ function startup(codeCachePath, nlsConfig) {
|
|||
}
|
||||
});
|
||||
|
||||
// VSCODE_GLOBALS: package/product.json
|
||||
globalThis._VSCODE_PRODUCT_JSON = require('../product.json');
|
||||
globalThis._VSCODE_PACKAGE_JSON = require('../package.json');
|
||||
|
||||
// Load main in AMD
|
||||
perf.mark('code/willLoadMainBundle');
|
||||
require('./bootstrap-amd').load('vs/code/electron-main/main', () => {
|
||||
|
|
9
src/typings/vscode-globals.d.ts
vendored
9
src/typings/vscode-globals.d.ts
vendored
|
@ -5,6 +5,15 @@
|
|||
|
||||
declare global {
|
||||
|
||||
/**
|
||||
* @deprecated You MUST use `IProductService` whenever possible.
|
||||
*/
|
||||
var _VSCODE_PRODUCT_JSON: Record<string, any>;
|
||||
/**
|
||||
* @deprecated You MUST use `IProductService` whenever possible.
|
||||
*/
|
||||
var _VSCODE_PACKAGE_JSON: Record<string, any>;
|
||||
|
||||
/**
|
||||
* @deprecated node modules that are in used in a context that
|
||||
* shouldn't have access to node_modules (node-free renderer or
|
||||
|
|
|
@ -3,11 +3,9 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { FileAccess } from 'vs/base/common/network';
|
||||
import { globals } from 'vs/base/common/platform';
|
||||
import { env } from 'vs/base/common/process';
|
||||
import { IProductConfiguration } from 'vs/base/common/product';
|
||||
import { dirname, joinPath } from 'vs/base/common/resources';
|
||||
import { ISandboxConfiguration } from 'vs/base/parts/sandbox/common/sandboxTypes';
|
||||
|
||||
/**
|
||||
|
@ -24,14 +22,10 @@ if (typeof globals.vscode !== 'undefined' && typeof globals.vscode.context !== '
|
|||
throw new Error('Sandbox: unable to resolve product configuration from preload script.');
|
||||
}
|
||||
}
|
||||
|
||||
// Native node.js environment
|
||||
else if (typeof require?.__$__nodeRequire === 'function') {
|
||||
|
||||
// Obtain values from product.json and package.json
|
||||
const rootPath = dirname(FileAccess.asFileUri(''));
|
||||
|
||||
product = require.__$__nodeRequire(joinPath(rootPath, 'product.json').fsPath);
|
||||
// _VSCODE environment
|
||||
else if (globalThis._VSCODE_PRODUCT_JSON && globalThis._VSCODE_PACKAGE_JSON) {
|
||||
// Obtain values from product.json and package.json-data
|
||||
product = globalThis._VSCODE_PRODUCT_JSON as IProductConfiguration;
|
||||
|
||||
// Running out of sources
|
||||
if (env['VSCODE_DEV']) {
|
||||
|
@ -47,7 +41,7 @@ else if (typeof require?.__$__nodeRequire === 'function') {
|
|||
// want to have it running out of sources so we
|
||||
// read it from package.json only when we need it.
|
||||
if (!product.version) {
|
||||
const pkg = require.__$__nodeRequire(joinPath(rootPath, 'package.json').fsPath) as { version: string };
|
||||
const pkg = globalThis._VSCODE_PACKAGE_JSON as { version: string };
|
||||
|
||||
Object.assign(product, {
|
||||
version: pkg.version
|
||||
|
|
|
@ -81,6 +81,9 @@ globalThis._VSCODE_NODE_MODULES = new Proxy(Object.create(null), {
|
|||
return target[mod];
|
||||
}
|
||||
});
|
||||
// VSCODE_GLOBALS: package/product.json
|
||||
globalThis._VSCODE_PRODUCT_JSON = (require.__$__nodeRequire ?? require)('../../../product.json');
|
||||
globalThis._VSCODE_PACKAGE_JSON = (require.__$__nodeRequire ?? require)('../../../package.json');
|
||||
|
||||
const _tests_glob = '**/test/**/*.test.js';
|
||||
let loader;
|
||||
|
|
Loading…
Reference in a new issue