Skip to content

Commit 2f67dae

Browse files
committed
fixup! lib: expose primordials object
1 parent b74793f commit 2f67dae

File tree

3 files changed

+7
-15
lines changed

3 files changed

+7
-15
lines changed

lib/internal/bootstrap/loaders.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ const {
5252
ObjectKeys,
5353
ObjectPrototypeHasOwnProperty,
5454
ReflectGet,
55-
ReflectGetOwnPropertyDescriptor,
5655
SafeMap,
5756
SafeSet,
5857
String,
@@ -217,19 +216,12 @@ class NativeModule {
217216
}
218217

219218
// Used by user-land module loaders to compile and load builtins.
220-
compileForPublicLoader(isPreloading) {
219+
compileForPublicLoader() {
221220
if (!this.canBeRequiredByUsers) {
222221
// No code because this is an assertion against bugs
223222
// eslint-disable-next-line no-restricted-syntax
224223
throw new Error(`Should not compile ${this.id} for public use`);
225224
}
226-
if (isPreloading) {
227-
ObjectDefineProperty(
228-
this, 'isPreloading',
229-
ReflectGetOwnPropertyDescriptor(
230-
nativeModuleRequire('internal/modules/cjs/loader').Module.prototype,
231-
'isPreloading'));
232-
}
233225
this.compileForInternalLoader();
234226
if (!this.exportKeys) {
235227
// When using --expose-internals, we do not want to reflect the named

lib/internal/modules/cjs/helpers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ let debug = require('internal/util/debuglog').debuglog('module', (fn) => {
3232
// TODO: Use this set when resolving pkg#exports conditions in loader.js.
3333
const cjsConditions = new SafeSet(['require', 'node', ...userConditions]);
3434

35-
function loadNativeModule(filename, request, isPreloading) {
35+
function loadNativeModule(filename, request) {
3636
const mod = NativeModule.map.get(filename);
3737
if (mod) {
3838
debug('load native module %s', request);
39-
mod.compileForPublicLoader(isPreloading);
39+
mod.compileForPublicLoader();
4040
return mod;
4141
}
4242
}

lib/internal/modules/cjs/loader.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,9 @@ ObjectDefineProperty(Module, 'wrapper', {
233233
}
234234
});
235235

236-
ObjectDefineProperty(Module.prototype, 'isPreloading', {
237-
get() { return isPreloading; }
238-
});
236+
const isPreloadingDesc = { get() { return isPreloading; } };
237+
ObjectDefineProperty(Module.prototype, 'isPreloading', isPreloadingDesc);
238+
ObjectDefineProperty(NativeModule.prototype, 'isPreloading', isPreloadingDesc);
239239

240240
function getModuleParent() {
241241
return moduleParentCache.get(this);
@@ -781,7 +781,7 @@ Module._load = function(request, parent, isMain) {
781781
}
782782
}
783783

784-
const mod = loadNativeModule(filename, request, isPreloading);
784+
const mod = loadNativeModule(filename, request);
785785
if (mod && mod.canBeRequiredByUsers) return mod.exports;
786786

787787
// Don't call updateChildren(), Module constructor already does.

0 commit comments

Comments
 (0)