From 2ea7a954eeb2b931e6ecf8b46455b08748da2264 Mon Sep 17 00:00:00 2001 From: Owen Buckley Date: Sat, 26 Feb 2022 09:26:58 -0800 Subject: [PATCH] force ESM style path separators --- packages/cli/src/plugins/resource/plugin-node-modules.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/plugins/resource/plugin-node-modules.js b/packages/cli/src/plugins/resource/plugin-node-modules.js index 129b8a775..88f2ff61c 100644 --- a/packages/cli/src/plugins/resource/plugin-node-modules.js +++ b/packages/cli/src/plugins/resource/plugin-node-modules.js @@ -21,7 +21,8 @@ const updateImportMap = (entry, entryPath) => { entryPath = `${entryPath}.js`; } - importMap[entry] = entryPath; + // handle WIn v Unix-style path separators and force to / + importMap[entry.replace(/\\/g, '/')] = entryPath.replace(/\\/g, '/'); }; // handle ESM paths that have varying levels of nesting, e.g. export * from '../../something.js' @@ -29,7 +30,8 @@ const updateImportMap = (entry, entryPath) => { async function resolveRelativeSpecifier(specifier, modulePath, dependency) { const absoluteNodeModulesLocation = await getNodeModulesLocationForPackage(dependency); - return `${dependency}${path.join(path.dirname(modulePath), specifier).replace(absoluteNodeModulesLocation, '')}`; + // handle WIn v Unix-style path separators and force to / + return `${dependency}${path.join(path.dirname(modulePath), specifier).replace(/\\/g, '/').replace(absoluteNodeModulesLocation.replace(/\\/g, '/', ''), '')}`; } const getPackageEntryPath = async (packageJson) => {