Skip to content

Commit

Permalink
fixup!: urlToFilename
Browse files Browse the repository at this point in the history
  • Loading branch information
JakobJingleheimer committed Apr 13, 2024
1 parent 585ac6d commit 3b11105
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/internal/modules/esm/translators.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const { dirname, extname, isAbsolute } = require('path');
const {
loadBuiltinModule,
stripBOM,
urlToFilename,
} = require('internal/modules/helpers');
const {
kIsCachedByESMLoader,
Expand Down Expand Up @@ -243,7 +244,7 @@ function loadCJSModule(module, source, url, filename) {
}
}
const { url: resolvedURL } = cascadedLoader.resolveSync(specifier, url, kEmptyObject);
return StringPrototypeStartsWith(resolvedURL, 'file://') ? fileURLToPath(resolvedURL) : resolvedURL;
return urlToFilename(resolvedURL);
});
setOwnProperty(requireFn, 'main', process.mainModule);

Expand All @@ -265,7 +266,7 @@ const cjsCache = new SafeMap();
function createCJSModuleWrap(url, source, isMain, loadCJS = loadCJSModule) {
debug(`Translating CJSModule ${url}`);

const filename = StringPrototypeStartsWith(url, 'file://') ? fileURLToPath(url) : url;
const filename = urlToFilename(url);
// In case the source was not provided by the `load` step, we need fetch it now.
source = stringify(source ?? getSource(new URL(url)).source);

Expand Down

0 comments on commit 3b11105

Please sign in to comment.