-
-
Notifications
You must be signed in to change notification settings - Fork 296
New issue
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
@web/rollup-plugin-import-meta-assets fails if encountering any reference to a directory #2421
Comments
Why should they be ignored and not resolved to a correct dir path? I'm thinking of a use-case where one might resolve a dir once and then construct paths to images within this dir. Am I missing smth in regard to how directories are different in the path resolution algorithm? |
If patterns can be resolved also to a dir path then that would be even better considering the use case that you mentioned (currently such patterns produce an error/a warning but are not resolved). I think it depends on how one sees the scope of the plugin. When I made the pull request, I had a narrower scope in mind: if there is an asset then the plugin should bundle it, otherwise do nothing. That was my impression when reading the docs. OTOH, one could think of a wider scope such as:
From my point of view, both options are agreeable, but the second one is more appealing. Please let me know how you would like to proceed -- thanks! |
@bashmish Sorry, my fingers were faster than my brain... On second thought, resolving a dir path does not make sense; what should it be resolved to? There is no corresponding asset. So please disregard the second option I mentioned above. |
@undecaf do you mean it doesn't make sense in the context of assets or in general? I agree that the scope of this plugin should focus on assets only. But I struggle to understand what the use case for |
@bashmish In the context of assets (i.e. like But resolving resolve something like e.g. |
@bashmish |
Thanks for explaining the use-case, it makes it much more clear. I think it's not about directories though. The tools might include other paths that need to be resolved in runtime only. Can you use If not, maybe we need another config to |
If Therefore my pull request does not change the bundling result compared to what the current plugin version produces; it just silences the directory warning (if
I am the author of a package which contains statements like Besides, as that package is a library, all consumers of that package would have to configure the Rollup plugin with |
Then indeed current I myself ran into similar difficulties with another plugin This is another plugin and another use-case, but very similar. After that on the back of my head I remembered that we might need to add more fine-grained control over specific assets that we are processing. That's why I was hesitating to make assumptions like "all directory paths should be ignored". But I also checked the file https://github.com/modernweb-dev/web/blob/master/packages/rollup-plugin-import-meta-assets/src/rollup-plugin-import-meta-assets.js and see that we say:
And in docs (https://github.com/modernweb-dev/web/blob/master/docs/docs/building/rollup-plugin-import-meta-assets.md) we say:
Which makes me think that paths without extensions should be skipped, which effectively means ignoring directories (although a path without an extension can be a file too). I'll review your PR now. |
And a path with an extension could also be a directory. IMHO one has to look into the file system, and then
My pull request makes the plugin behave like that. |
fix(rollup-plugin-import-meta-assets): fix #2421
Observed behavior
If any module contains a pattern that references a directory, such as
then this plugin fails with the message
EISDIR: illegal operation on a directory, read
. SettingwarnOnError: true
does not help: if the offending module also contains a pattern that references a file then that file will not be added to the rollup pipeline.Expected behavior
Patterns that reference directories should be silently ignored by default.
Edit:
My apologies, I just noticed that -- as opposed to what I wrote above -- setting
warnOnError: true
does help, and other file references are added to the rollup pipeline.Nevertheless, IMHO if a pattern references a directory then this was probably intended and should not be considered as an error, not even as a not-fatal one.
The text was updated successfully, but these errors were encountered: