-
Notifications
You must be signed in to change notification settings - Fork 31k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove __$__nodeRequire usages #166686
Remove __$__nodeRequire usages #166686
Changes from all commits
2d6ad4b
8dd8d21
bcffe19
380ac1e
824c70b
e14d874
d555777
cd0a272
34ce6e2
8295518
0dac468
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
// AMD2ESM mirgation relevant | ||
|
||
declare global { | ||
|
||
/** | ||
* @deprecated node modules that are in used in a context that | ||
* shouldn't have access to node_modules (node-free renderer or | ||
* shared process) | ||
*/ | ||
var _VSCODE_NODE_MODULES: { | ||
crypto: typeof import('crypto'); | ||
zlib: typeof import('zlib'); | ||
net: typeof import('net'); | ||
os: typeof import('os'); | ||
module: typeof import('module'); | ||
['native-watchdog']: typeof import('native-watchdog') | ||
perf_hooks: typeof import('perf_hooks'); | ||
|
||
['vsda']: any | ||
['vscode-encrypt']: any | ||
} | ||
} | ||
|
||
// fake export to make global work | ||
export { } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
// AMD2ESM mirgation relevant | ||
|
||
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>; | ||
|
||
} | ||
|
||
// fake export to make global work | ||
export { } |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is lazy to avoid a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the ESM future there will be no more way to synchronously load anything. So, the only way forward will be something like |
||
|
||
Object.assign(product, { | ||
version: pkg.version | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason product/package.json cannot go through the same proxy above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah,
_VSCODE_NODE_MODULES
is debt and must eventually disappear whereas the_VSCODE_PRODUCT_JSON
and_VSCODE_PACKAGE_JSON
globals are likely staying (being merged withvscode.context...
)