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

fix: isFilePath not working on windows #6

Merged
merged 12 commits into from
Apr 10, 2017

Conversation

zacharygolba
Copy link
Contributor

@zacharygolba zacharygolba commented Sep 11, 2016

Closes #3

Uses path.sep to generate a RegExp that works for both Windows and UNIX based systems.

Windows: /^\.?\\/
Linux/OSX: /^\.?\//

Copy link

@cdunford cdunford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a good change. It's not entirely clear what the expectation of isFilePath is - perhaps using path.parse and processing the output would be easier to understand.

@cdunford
Copy link

cdunford commented Sep 16, 2016

My issue seems to stem from the fact that I have absolute paths on windows. I added the following outside of if(isFilePath(updatedId)) and it resolves my issue:

 var match = resolve.map(function (ext) {
    return updatedId + ext;
  }).find(exists);

  if (match) {
    return match;
  }

@coveralls
Copy link

coveralls commented Sep 18, 2016

Coverage Status

Coverage remained the same at 97.727% when pulling 6f1f484 on zacharygolba:fix-windows-file-paths into 7e33d7c on frostney:master.

szwacz and others added 6 commits March 7, 2017 22:54
* Don't confuse modules with similar names

* More bugfixes for similar module names

* Even more improvements for similar module names
@gaearon
Copy link

gaearon commented Apr 7, 2017

@Rich-Harris Could you take a look? Seems like without a fix for this (I’m not sure if it’s the right fix) we can’t build React on Windows: facebook/react#9350 (comment).

@Rich-Harris Rich-Harris mentioned this pull request Apr 7, 2017
@Rich-Harris
Copy link
Contributor

So, I created a dummy PR (#16) to try to coax Appveyor into testing this branch, and some tests are failing — possibly unrelated to #3. I haven't yet had a chance to investigate, will try and take a look soon. Appveyor output is here if anyone is interested.

@zacharygolba
Copy link
Contributor Author

So, I created a dummy PR (#16) to try to coax Appveyor into testing this branch, and some tests are failing — possibly unrelated to #3.

Nice! Is this a matter of tests needing an update or is there an issue with the implementation?

After a quick glance at the Appveyor output, it almost seems like this plugin assumes the existence of rollup-plugin-node-resolve.

Here is a link to an example of the resulting regex on windows. I added the g and m flags for demonstration purposes.

Let me know if there is anything I can do to help.

@Rich-Harris
Copy link
Contributor

Nice! Is this a matter of tests needing an update or is there an issue with the implementation?

I assume it's an issue(s) with the implementation. Not entirely sure, though — if anyone can check out the gh-3 branch (includes this branch, updated to latest master) on a Windows machine and see if they can get their head round it I'd be very grateful.

@zacharygolba
Copy link
Contributor Author

@Rich-Harris I got this working on macOS 10.12.4 as well as Windows 10 (running in a vm).

I changed the implementation to first convert windows paths into the posix equivalent and then further parsing/updates to the ids use the path.posix module to get the posix behavior regardless of the platform. This may allow for better compatibility with other plugins down stream.

If this looks promising, I can do some cleanup on the implementation and tests.

@zacharygolba
Copy link
Contributor Author

Here is a diff against the gh-3 branch for better context.

@Rich-Harris Rich-Harris merged commit 5c6144b into rollup:master Apr 10, 2017
@Rich-Harris
Copy link
Contributor

@zacharygolba thank you! looks like green lights all round. I'll cut a new release now so that we can finally close #3, I don't think there's any great need for further cleanup but totally up to you

🍻

@zacharygolba
Copy link
Contributor Author

@Rich-Harris Anytime! I'm happy to help out. 😃

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

Successfully merging this pull request may close these issues.

7 participants