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

Troubles with isFilePath on windows #3

Closed
lukeapage opened this issue Jun 14, 2016 · 6 comments
Closed

Troubles with isFilePath on windows #3

lukeapage opened this issue Jun 14, 2016 · 6 comments

Comments

@lukeapage
Copy link

lukeapage commented Jun 14, 2016

Hi,

I'm having trouble getting isFilePath to match on windows - and therefore am not getting extensions being resolved.

If I give an absolute resolved path to alias, the regex does not pass on windows (because its c:\a\b not \a\b\

If I give a relative path, it doesn't work because I need ../ at the begining.

I'm currently solving this by passing this alias

'alias': './../' + path.relative(path.resolve('.'), path_i_want)

perhaps the isFilePath could be /^(\.{0,2}[\/\\]|[a-z]:\/\/)/i - what do you think?

@lukeapage
Copy link
Author

this is the function causing an issue
https://github.com/frostney/rollup-plugin-alias/blob/master/src/index.js#L8

@lukeapage
Copy link
Author

My use-case was broken when I upgraded because of
#2
@yyx990803

@frostney
Copy link
Contributor

Hi @lukeapage, thank you for reporting the issue and I'm terribly sorry for the inconvenience. The regex looks good to me. I'm wondering if there isn't a Node.js built-in method that would do the check for us more predictably for different platforms?

@lukeapage
Copy link
Author

The trouble is that although there is an isAbsolute / isRelative what I think you want is - isAbsolute || isRelative, but excluding module_path/...
But I didn't write that function so I'm only guessing.
You could alternately always try resolving with a file extension and not add on .js if you fail to resolve..

@cdunford
Copy link

I am experiencing this - the pull request to resolve it works well for me.

@cool-Blue
Copy link

cool-Blue commented Apr 15, 2017

@Rich-Harris I think this should still be open? The original problem with relative addresses beginning with ../ remains.

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

No branches or pull requests

4 participants