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

Add "resolve" option to createFilter #61

Merged
merged 8 commits into from
May 15, 2019
Merged

Conversation

lukastaegert
Copy link
Member

This PR will add a new resolve option to createFilter to allow specifying a base directory other than process.cwd() or disable resolution altogether.

Resolves #39
Resolves #20

It is specified via an optional third parameter:
createFilter(includes, excludes, {resolve: '/my/base/dir'})

Passing a string as resolve will resolve patterns like this:
path.resolve(resolve, pattern)
instead of just
path.resolve(pattern)

Passing false will disable this behaviour altogether and directly use the supplied pattern (which is useful if you want to match virtual directories as well).

@eight04
Copy link

eight04 commented May 14, 2019

Can we have some tests against virtual modules?

expect(filter('\0proxy-modules:x')).toBe...
expect(filter('\0proxy-modules:' + path.resolve('x'))).toBe...

@lukastaegert
Copy link
Member Author

I allowed resolve: false to match ids starting with a \0, added a test and also a note to the readme. Note however that using : as a separator in your virtual ids can have an adverse effect on matching (I think minimatch confuses this with windows drive letters or similar), so you should probably use something else as separator and also consider this when putting full paths as substrings into virtual ids on Windows.

@lukastaegert
Copy link
Member Author

Ah, looking into your motivation, maybe I should also fix the names of proxy modules in rollup-plugin-commonjs...

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.

Why is createFilter is scoped to process.cwd? path.resolve in createFilter
2 participants