Skip to content

Commit e94dcd0

Browse files
force ESM style path separators
1 parent 714e8a8 commit e94dcd0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/cli/src/plugins/resource/plugin-node-modules.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,17 @@ const updateImportMap = (entry, entryPath) => {
2121
entryPath = `${entryPath}.js`;
2222
}
2323

24-
importMap[entry] = entryPath;
24+
// handle WIn v Unix-style path separators and force to /
25+
importMap[entry.replace(/\\/g, '/')] = entryPath.replace(/\\/g, '/');
2526
};
2627

2728
// handle ESM paths that have varying levels of nesting, e.g. export * from '../../something.js'
2829
// https://github.com/ProjectEvergreen/greenwood/issues/820
2930
async function resolveRelativeSpecifier(specifier, modulePath, dependency) {
3031
const absoluteNodeModulesLocation = await getNodeModulesLocationForPackage(dependency);
3132

32-
return `${dependency}${path.join(path.dirname(modulePath), specifier).replace(absoluteNodeModulesLocation, '')}`;
33+
// handle WIn v Unix-style path separators and force to /
34+
return `${dependency}${path.join(path.dirname(modulePath), specifier).replace(/\\/g, '/').replace(absoluteNodeModulesLocation.replace(/\\/g, '/', ''), '')}`;
3335
}
3436

3537
const getPackageEntryPath = async (packageJson) => {

0 commit comments

Comments
 (0)