-
Notifications
You must be signed in to change notification settings - Fork 17
Why is createFilter is scoped to process.cwd? #39
Comments
See rollup/rollup-pluginutils#39 for more background. Using a regex overrides the automatic scoping.
I'd be open to changing this to something more sensible, but we need to be careful about backwards compat etc. Would you be interested in working on a PR? |
What would a sensible back-compat approach be? An options object as the third arg to For now I've worked around by using a RegExp instead of a glob. It's not a pressing concern, just something that really threw me for a bit when my tests were failing. |
This seems to have another unintended effect too, whereby the path of the current directory is considered as part of the match pattern. Therefore, if your current directory contains characters that have special meaning in regexp, you might not match the files you expected to. |
I have run into similar problem. This kinda situation may occur frequently in a monorepo since 3-rd party dependencies are tend to be hoisted to the root directory. I understand that 3rd party files have better treated as externals and the problem would be resolved. But there still are circumstances where bundling certain dependencies is required (e.g. say rolling up the final output of the monorepo) |
Summary: rollup-pluginutils scopes include/exclude patterns provided to the current directory by prefixing the pattern with the current path. Unfortunately, if that path contains special characters that have an effect in regular expressions, they're not treated as literal. There's a bug open against this behaviour: rollup/rollup-pluginutils#39 Workaround it by providing include/exclude as regular expressions, which doesn't trigger this behaviour. Test Plan: Build in a directory named "qa^(2),2" Reviewers: #developer_tools, Jupiter, csnider Reviewed By: #developer_tools, Jupiter, csnider Subscribers: csnider JIRA Issues: IPD-102765 Differential Revision: https://phabricator.firmwareci.fitbit.com/D2258
the workaround is to use minimatch patterns starting with |
@sormy That workaround didn't work for me, it just mean that my plugin never matched any files. For now I've been using |
See this issue for more info: rollup/rollup-pluginutils#39
I created #61 to address this (as I need this myself for package side-effects in rollup-plugin-node-resolve). I would still stick with the default as it currently provides a consistent experience across the rollup ecosystem. However if you have special needs, you can now configure it. |
For the record, #61 does not resolve the problem with monorepo setup where dependencies are hoisted. Use #39 (comment) instead. |
rollup-pluginutils/src/createFilter.js
Line 6 in 0b1887c
If you invoke
createFilter()
with a string forinclude
orexclude
it'll be run throughpath.resolve
before it's passed tomm.matcher()
.Why?
It means that unless you pass a regular expression matcher all globs will only match files underneath
process.cwd()
. This cropped up as I tried to move my fixtures to the system temp folder and suddenly my plugin's filters stopped matching anything because they're all scoped. It seems like it'd be more intuitive for the glob to be passed tomm.matcher()
w/o the resolving.The text was updated successfully, but these errors were encountered: