Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

namedExports is using non-normalized resolved module path as module id #177

Closed
ezolenko opened this issue Mar 10, 2017 · 3 comments · Fixed by #406
Closed

namedExports is using non-normalized resolved module path as module id #177

ezolenko opened this issue Mar 10, 2017 · 3 comments · Fixed by #406

Comments

@ezolenko
Copy link

On windows, this can conflict with plugins using other resolvers. For example typescript's built-in resolver returns module paths using forward slashes, while commonjs takes output of resolve at face value. Since that happens to return system native path with backslashes (in ver 1.1.7 at least), mishaps can result depending on which plugin happened to resolve a given module first.

One way to fix it would be to normalize path before using it as a key.

@ezolenko ezolenko changed the title namedExports is using non-normalized resolved module paths as module id namedExports is using non-normalized resolved module path as module id Mar 10, 2017
@Rich-Harris
Copy link
Contributor

Thanks. This sounds like the sort of thing I'm liable to mess up if I try and fix it — any chance you could put a simple repro together that could be turned into a test case (or better yet, a PR with said test, or even a fix)?

@ezolenko
Copy link
Author

Reproducing it is the main problem, yeah. I only saw it on somebody else codebase...

@westonpace
Copy link

This is easily reproducible for me. I have created a stripped down example here: https://github.com/westonpace/rollup-issue-repro

Just run npm install followed by npm run rollup. It will fail on Windows but work on POSIX.

I was able to hack a fix in by changing the main function in index.js and changing the line:

customNamedExports[resolvedId] = options.namedExports[id];

to:

customNamedExports[resolvedId] = options.namedExports[id];
customNamedExports[resolvedId.replace(/\\/g,'/')] = options.namedExports[id];

I needed both because some paths got munged by the incoming plugins and some did not. Not sure if this is the cleanest or preferred fix however.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants