We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rollup filter doesn't match paths located outside base directory.
root βββ app βΒ Β βββ index.html βΒ Β βββ index.jsx βΒ Β βββ circle.svg βββ outsider βββ square.svg Β Β βββ triangle.svg
/root/app/index.jsx
import Circle from './circle.svg'; import Square from '../outsider/square.svg';
Steps to reproduce the behavior:
/root/app
@svgr/rollup
/root/app/circle.svg is correctly picked up and transformed /root/outsider/square.svg is filtered out and skipped
/root/app/circle.svg
/root/outsider/square.svg
Both /root/app/circle.svg and /root/outsider/square.svg should be picked up and transformed
Rollup plugin utils filter is used with **/*.svg to match relevant imports to transform:
**/*.svg
svgr/packages/rollup/src/index.ts
Line 45 in 161d1b1
Which is then resolved to /root/app/**/*.svg (considering the example above) here: https://github.com/rollup/rollup-pluginutils/blob/162b1db4b7b08f314493b53a7b817c086be26af4/src/createFilter.ts#L10
/root/app/**/*.svg
Which then only matches files inside the directory where rollup is running.
The use of the filter is correct here, and the root problem has already been fixed in rollup/plugins#517. The catch is that rollup-pluginutils has been renamed to @rollup/pluginutils and the fix happened after the move.
rollup-pluginutils
@rollup/pluginutils
So the real fix is to use the renamed module.
It's possible to work around this issue by leveraging this condition: https://github.com/rollup/rollup-pluginutils/blob/162b1db4b7b08f314493b53a7b817c086be26af4/src/createFilter.ts#L17-L18
If the pattern is a regex instead of a string, the resolve is skipped and the filter correctly matches the files it's supposed to match.
// ... svgrRollupPlugin({ include: [/\.svg$/], }), // ...
## System: - OS: macOS 12.2.1 - CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz - Memory: 47.63 MB / 16.00 GB - Shell: 5.8 - /bin/zsh ## Binaries: - Node: 16.14.0 - ~/.nvm/versions/node/v16.14.0/bin/node - npm: 8.3.1 - ~/.nvm/versions/node/v16.14.0/bin/npm
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
π Bug report
Rollup filter doesn't match paths located outside base directory.
To reproduce
/root/app/index.jsx
Steps to reproduce the behavior:
/root/app
with the@svgr/rollup
pluginActual behavior
/root/app/circle.svg
is correctly picked up and transformed/root/outsider/square.svg
is filtered out and skippedExpected behavior
Both
/root/app/circle.svg
and/root/outsider/square.svg
should be picked up and transformedWhy it happens
Rollup plugin utils filter is used with
**/*.svg
to match relevant imports to transform:svgr/packages/rollup/src/index.ts
Line 45 in 161d1b1
Which is then resolved to
/root/app/**/*.svg
(considering the example above) here:https://github.com/rollup/rollup-pluginutils/blob/162b1db4b7b08f314493b53a7b817c086be26af4/src/createFilter.ts#L10
Which then only matches files inside the directory where rollup is running.
The fix
The use of the filter is correct here, and the root problem has already been fixed in rollup/plugins#517. The catch is that
rollup-pluginutils
has been renamed to@rollup/pluginutils
and the fix happened after the move.So the real fix is to use the renamed module.
The workaround
It's possible to work around this issue by leveraging this condition:
https://github.com/rollup/rollup-pluginutils/blob/162b1db4b7b08f314493b53a7b817c086be26af4/src/createFilter.ts#L17-L18
If the pattern is a regex instead of a string, the resolve is skipped and the filter correctly matches the files it's supposed to match.
Environment info
The text was updated successfully, but these errors were encountered: