Skip to content

Commit

Permalink
fix windows cache path lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Nov 23, 2017
1 parent 10a0650 commit ffe969a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/internal/loader/ModuleRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@ loaders.set('esm', async (url) => {
});

// Strategy for loading a node-style CommonJS module
const isWindows = process.platform === 'win32';
const winSepRegEx = /\//g;
loaders.set('cjs', async (url) => {
const pathname = internalURLModule.getPathFromURL(new URL(url));
const module = CJSModule._cache[pathname];
const module = CJSModule._cache[
isWindows ? pathname.replace(winSepRegEx, '\\') : pathname];

This comment has been minimized.

Copy link
@jdalton

jdalton Nov 23, 2017

Member

Why doesn't the path helper produce the normalized path for the platform like other path helpers? The string.replace here is a sign the helper needs to be fixed.

if (module && module.loaded) {
const ctx = createDynamicModule(['default'], url, undefined);
ctx.reflect.exports.default.set(module.exports);
Expand Down

0 comments on commit ffe969a

Please sign in to comment.