mirror of
https://github.com/nodejs/node.git
synced 2025-12-28 07:50:41 +00:00
module: fix crash when built-in module export a default key
PR-URL: https://github.com/nodejs/node/pull/51481 Fixes: https://github.com/nodejs/node/issues/51480 Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
This commit is contained in:
parent
eb4432c12c
commit
a7729737cf
@ -350,7 +350,9 @@ class BuiltinModule {
|
||||
const url = `node:${this.id}`;
|
||||
const builtin = this;
|
||||
const exportsKeys = ArrayPrototypeSlice(this.exportKeys);
|
||||
ArrayPrototypePush(exportsKeys, 'default');
|
||||
if (!ArrayPrototypeIncludes(exportsKeys, 'default')) {
|
||||
ArrayPrototypePush(exportsKeys, 'default');
|
||||
}
|
||||
this.module = new ModuleWrap(
|
||||
url, undefined, exportsKeys,
|
||||
function() {
|
||||
|
||||
8
test/parallel/test-process-default.js
Normal file
8
test/parallel/test-process-default.js
Normal file
@ -0,0 +1,8 @@
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
const assert = require('node:assert');
|
||||
|
||||
process.default = 1;
|
||||
import('node:process').then(common.mustCall((processModule) => {
|
||||
assert.strictEqual(processModule.default.default, 1);
|
||||
}));
|
||||
Loading…
Reference in New Issue
Block a user