Specifying include/exclude breaks packaging
halostatue opened this issue · 3 comments
Background: I am experimenting with methods to potentially fix some nonsense perpetrated by Webpack in components I am incorporating into my application. Specifically, I am working with Vue.js and am using rollup, rollup-plugin-vue, and rollup-plugin-babel (as well as several others, as my example repo demonstrates).
When I specify the babel configuration as:
babel({ exclude: ['node_modules/**'] })
Everything works. If, however, I specify an include
that contradicts the exclude
:
babel({ exclude: ['node_modules/**'], include: ['node_modules/vue-password/**'] })
things break. I have created a repository (rollup-babel-plugin-include-exclude-issue) that demonstrates this. It’s not exactly minimal, but I have been able to determine that it is the babel plugin that is causing the problem through some careful checking of configuration options.
I have received various errors including:
[!] (plugin Rollup Core) Error: Could not load fs (imported by …/rollup-babel-plugin-include-exclude-issue/node_modules/graphql.macro/es/utils/expandImports.js): ENOENT: no such file or directory, open 'fs'
and other related errors (specifically related to graphql.macro
) that appear to be somewhat random.
It seems to me that this should work (exclude all items from node_modules
except the items that I have whitelisted because I’m doing something potentially stupid), or at least continue the compile…but I’m not sure what’s going on here.
This really depends on which of those options (include/exclude) are considered as the one with more priority. You could always make a compelling argument (with usage examples) for current semantics, and you can do the same for your proposed one.
This plugin actually uses "standard" rollup-pluginutils and its createFilter helper to handle those 2, so I don't plan to change how this behaves as it's handled externally and should be handled in the same way across all rollup plugins which use include/exclude options.
The good thing is that you actually can use a regexp instead of a glob so maybe it would be easier for you to create a single include (or exclude) rule with RegExp because when you mix both of those options then things become hard to reason about and confusing.
I just opened rollup/rollup-pluginutils#67 to suggest a documentation update. I will suggest the same documentation update for rollup-plugin-babel from a comment on rollup/rollup-pluginutils#4. I believe that this will satisfy my issue, although I could wish for better handling.
The reported issue in rollup-pluginutils
has been closed because this was actually documented there. Seems like this issue can be closed too. If you have any further issues - please create a new one.