Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5c879a9

Browse filesBrowse files
guybedforddanielleadams
authored andcommitted
module: fix builtin reexport tracing
PR-URL: #35500 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
1 parent 91ef862 commit 5c879a9
Copy full SHA for 5c879a9

File tree

Expand file treeCollapse file tree

5 files changed

+31
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

5 files changed

+31
-2
lines changed
Open diff view settings
Collapse file

‎lib/internal/modules/esm/translators.js‎

Copy file name to clipboardExpand all lines: lib/internal/modules/esm/translators.js
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function lazyTypes() {
2424
}
2525

2626
const { readFileSync } = require('fs');
27-
const { extname } = require('path');
27+
const { extname, isAbsolute } = require('path');
2828
const {
2929
stripBOM,
3030
loadNativeModule
@@ -244,7 +244,8 @@ function cjsPreparseModuleExports(filename) {
244244
continue;
245245
}
246246
const ext = extname(resolved);
247-
if (ext === '.js' || ext === '.cjs' || !CJSModule._extensions[ext]) {
247+
if ((ext === '.js' || ext === '.cjs' || !CJSModule._extensions[ext]) &&
248+
isAbsolute(resolved)) {
248249
const { exportNames: reexportNames } = cjsPreparseModuleExports(resolved);
249250
for (const name of reexportNames)
250251
exportNames.add(name);
Collapse file
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const fixtures = require('../common/fixtures');
5+
const { spawn } = require('child_process');
6+
const assert = require('assert');
7+
8+
const entry = fixtures.path('/es-modules/builtin-imports-case.mjs');
9+
10+
const child = spawn(process.execPath, [entry]);
11+
child.stderr.setEncoding('utf8');
12+
let stdout = '';
13+
child.stdout.setEncoding('utf8');
14+
child.stdout.on('data', (data) => {
15+
stdout += data;
16+
});
17+
child.on('close', common.mustCall((code, signal) => {
18+
assert.strictEqual(code, 0);
19+
assert.strictEqual(signal, null);
20+
assert.strictEqual(stdout, 'ok\n');
21+
}));
Collapse file
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { strictEqual } from 'assert';
2+
import './dep1.js';
3+
import { assert as depAssert } from './dep2.js';
4+
strictEqual(depAssert.strictEqual, strictEqual);
5+
console.log('ok');
Collapse file

‎test/fixtures/es-modules/dep1.js‎

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('assert');
Collapse file

‎test/fixtures/es-modules/dep2.js‎

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
exports.assert = require('assert');

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.