Description
Thanks for your work on both of the great react-css-modules packages. I want to clarify if a behavior that we experience is expected or open to modification (or of course to be solved by other means).
I am excluding node_modules via the exclude option, which is respected in ImportDeclaration(...)
, but not in JSXElement(...)
. The latter will eventually make assertions on excluded files (in our case throwing an error if it finds a styleName prop but no supported imports).
Use case:
This affects us as we are maintaining a non-bundled internal component library that still uses the react-css-modules
HOC (as well as a deprecated CSS preprocessor without a postcss syntax) and cannot be immediately refactored to the babel plugin. For the apps that make use of our internal dependency however we want to start using the babel plugin while gradually migrating the other parts over time.
As mentioned above I would like to clarify if opting out in the JSXElement transform if the component's path matches the exclude setting makes sense in your opinion.
// just a quick and dirty check to see if it works in our case
JSXElement(path, stats) {
const filename = stats.file.opts.filename;
if (stats.opts.exclude && filename.match(new RegExp(stats.opts.exclude))) {
return;
}
// ...
}