mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
lib,src: remove --experimental-policy
Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com> PR-URL: https://github.com/nodejs/node/pull/52583 Refs: https://github.com/nodejs/node/issues/52575 Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
This commit is contained in:
parent
9a1df15ee7
commit
951af83033
90 changed files with 116 additions and 5720 deletions
|
@ -140,11 +140,6 @@ const fs = require('fs');
|
|||
const path = require('path');
|
||||
const { internalModuleStat } = internalBinding('fs');
|
||||
const { safeGetenv } = internalBinding('credentials');
|
||||
const {
|
||||
privateSymbols: {
|
||||
require_private_symbol,
|
||||
},
|
||||
} = internalBinding('util');
|
||||
const {
|
||||
getCjsConditions,
|
||||
initializeCjsConditions,
|
||||
|
@ -156,9 +151,6 @@ const {
|
|||
} = require('internal/modules/helpers');
|
||||
const packageJsonReader = require('internal/modules/package_json_reader');
|
||||
const { getOptionValue, getEmbedderOptions } = require('internal/options');
|
||||
const policy = getLazy(
|
||||
() => (getOptionValue('--experimental-policy') ? require('internal/process/policy') : null),
|
||||
);
|
||||
const shouldReportRequiredModules = getLazy(() => process.env.WATCH_REPORT_DEPENDENCIES);
|
||||
|
||||
const permission = require('internal/process/permission');
|
||||
|
@ -197,25 +189,6 @@ let requireDepth = 0;
|
|||
let isPreloading = false;
|
||||
let statCache = null;
|
||||
|
||||
/**
|
||||
* Our internal implementation of `require`.
|
||||
* @param {Module} module Parent module of what is being required
|
||||
* @param {string} id Specifier of the child module being imported
|
||||
*/
|
||||
function internalRequire(module, id) {
|
||||
validateString(id, 'id');
|
||||
if (id === '') {
|
||||
throw new ERR_INVALID_ARG_VALUE('id', id,
|
||||
'must be a non-empty string');
|
||||
}
|
||||
requireDepth++;
|
||||
try {
|
||||
return Module._load(id, module, /* isMain */ false);
|
||||
} finally {
|
||||
requireDepth--;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a path's properties, using an in-memory cache to minimize lookups.
|
||||
* @param {string} filename Absolute path to the file
|
||||
|
@ -294,17 +267,6 @@ function Module(id = '', parent) {
|
|||
this.filename = null;
|
||||
this.loaded = false;
|
||||
this.children = [];
|
||||
let redirects;
|
||||
const manifest = policy()?.manifest;
|
||||
if (manifest) {
|
||||
const moduleURL = pathToFileURL(id);
|
||||
redirects = manifest.getDependencyMapper(moduleURL);
|
||||
// TODO(rafaelgss): remove the necessity of this branch
|
||||
setOwnProperty(this, 'require', makeRequireFunction(this, redirects));
|
||||
// eslint-disable-next-line no-proto
|
||||
setOwnProperty(this.__proto__, 'require', makeRequireFunction(this, redirects));
|
||||
}
|
||||
this[require_private_symbol] = internalRequire;
|
||||
}
|
||||
|
||||
/** @type {Record<string, Module>} */
|
||||
|
@ -1295,7 +1257,6 @@ Module.prototype.load = function(filename) {
|
|||
|
||||
/**
|
||||
* Loads a module at the given file path. Returns that module's `exports` property.
|
||||
* Note: when using the experimental policy mechanism this function is overridden.
|
||||
* @param {string} id
|
||||
* @throws {ERR_INVALID_ARG_TYPE} When `id` is not a string
|
||||
*/
|
||||
|
@ -1411,14 +1372,7 @@ function wrapSafe(filename, content, cjsModuleInstance, codeCache, format) {
|
|||
* @param {'module'|'commonjs'|undefined} format Intended format of the module.
|
||||
*/
|
||||
Module.prototype._compile = function(content, filename, format) {
|
||||
let moduleURL;
|
||||
let redirects;
|
||||
const manifest = policy()?.manifest;
|
||||
if (manifest) {
|
||||
moduleURL = pathToFileURL(filename);
|
||||
redirects = manifest.getDependencyMapper(moduleURL);
|
||||
manifest.assertIntegrity(moduleURL, content);
|
||||
}
|
||||
|
||||
let compiledWrapper;
|
||||
if (format !== 'module') {
|
||||
|
@ -1572,12 +1526,6 @@ Module._extensions['.js'] = function(module, filename) {
|
|||
Module._extensions['.json'] = function(module, filename) {
|
||||
const content = fs.readFileSync(filename, 'utf8');
|
||||
|
||||
const manifest = policy()?.manifest;
|
||||
if (manifest) {
|
||||
const moduleURL = pathToFileURL(filename);
|
||||
manifest.assertIntegrity(moduleURL, content);
|
||||
}
|
||||
|
||||
try {
|
||||
setOwnProperty(module, 'exports', JSONParse(stripBOM(content)));
|
||||
} catch (err) {
|
||||
|
@ -1592,12 +1540,6 @@ Module._extensions['.json'] = function(module, filename) {
|
|||
* @param {string} filename The file path of the module
|
||||
*/
|
||||
Module._extensions['.node'] = function(module, filename) {
|
||||
const manifest = policy()?.manifest;
|
||||
if (manifest) {
|
||||
const content = fs.readFileSync(filename);
|
||||
const moduleURL = pathToFileURL(filename);
|
||||
manifest.assertIntegrity(moduleURL, content);
|
||||
}
|
||||
// Be aware this doesn't use `content`
|
||||
return process.dlopen(module, path.toNamespacedPath(filename));
|
||||
};
|
||||
|
@ -1708,7 +1650,7 @@ Module._preloadModules = function(requests) {
|
|||
}
|
||||
}
|
||||
for (let n = 0; n < requests.length; n++) {
|
||||
internalRequire(parent, requests[n]);
|
||||
parent.require(requests[n]);
|
||||
}
|
||||
isPreloading = false;
|
||||
};
|
||||
|
@ -1728,7 +1670,7 @@ Module.syncBuiltinESMExports = function syncBuiltinESMExports() {
|
|||
ObjectDefineProperty(Module.prototype, 'constructor', {
|
||||
__proto__: null,
|
||||
get: function() {
|
||||
return policy() ? undefined : Module;
|
||||
return Module;
|
||||
},
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue