Skip to content

Commit

Permalink
fixup! esm: skip file: URL conversion to path when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 committed Jan 22, 2023
1 parent 3a61d80 commit 1ceaa2c
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions lib/internal/modules/esm/translators.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ const {
Module: CJSModule,
cjsParseCache
} = require('internal/modules/cjs/loader');
const internalURLModule = require('internal/url');
const { fileURLToPath, URL } = require('url');
const { fileURLToPath, URL } = require('internal/url');
let debug = require('internal/util/debuglog').debuglog('esm', (fn) => {
debug = fn;
});
Expand Down Expand Up @@ -147,9 +146,7 @@ translators.set('commonjs', async function commonjsStrategy(url, source,
isMain) {
debug(`Translating CJSModule ${url}`);

let filename = internalURLModule.fileURLToPath(new URL(url));
if (isWindows)
filename = StringPrototypeReplaceAll(filename, '/', '\\');
const filename = fileURLToPath(new URL(url));

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

0 comments on commit 1ceaa2c

Please sign in to comment.