Skip to content

Commit

Permalink
force ESM style path separators
Browse files Browse the repository at this point in the history
  • Loading branch information
thescientist13 committed Feb 26, 2022
1 parent 23106c5 commit 2ea7a95
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/cli/src/plugins/resource/plugin-node-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@ 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'
// https://github.com/ProjectEvergreen/greenwood/issues/820
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) => {
Expand Down

0 comments on commit 2ea7a95

Please sign in to comment.