Skip to content

Commit 1ceaa2c

Browse files
committed
fixup! esm: skip file: URL conversion to path when possible
1 parent 3a61d80 commit 1ceaa2c

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

lib/internal/modules/esm/translators.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ const {
3535
Module: CJSModule,
3636
cjsParseCache
3737
} = require('internal/modules/cjs/loader');
38-
const internalURLModule = require('internal/url');
39-
const { fileURLToPath, URL } = require('url');
38+
const { fileURLToPath, URL } = require('internal/url');
4039
let debug = require('internal/util/debuglog').debuglog('esm', (fn) => {
4140
debug = fn;
4241
});
@@ -147,9 +146,7 @@ translators.set('commonjs', async function commonjsStrategy(url, source,
147146
isMain) {
148147
debug(`Translating CJSModule ${url}`);
149148

150-
let filename = internalURLModule.fileURLToPath(new URL(url));
151-
if (isWindows)
152-
filename = StringPrototypeReplaceAll(filename, '/', '\\');
149+
const filename = fileURLToPath(new URL(url));
153150

154151
if (!cjsParse) await initCJSParse();
155152
const { module, exportNames } = cjsPreparseModuleExports(filename);

0 commit comments

Comments
 (0)