Skip to content
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

Add ~ and / support to the glob resolver #9188

Merged
merged 12 commits into from
Nov 15, 2023
Merged

Conversation

jondlm
Copy link
Contributor

@jondlm jondlm commented Aug 9, 2023

↪️ Pull Request

Fixes #8704 by adding support for ~ and absolute paths with the glob resolver. ~ resolves to the nearest package boundary and / to the project root.

🧑‍💻 Tip: you can view this PR by commit for a smoother review.

💻 Examples

This allows folks using the glob resolver to import globs like:

  • import images from '~/images/*.png (package boundary)
  • import images from '/dir/images/*.png' (project root)

🚨 Test instructions

I included integration tests that cover this feature.

✔️ PR Todo

  • Added/updated unit tests for this change
  • Filled out test instructions (In case there aren't any unit tests)
  • Included links to related issues/PRs

@devongovett
Copy link
Member

Thanks for the PR. Absolute and tilde specifiers in Parcel have a different meaning. See the docs here: https://parceljs.org/features/dependency-resolution/#absolute-specifiers. I guess if we add support in the glob resolver they should match the default resolver as well, so absolute should resolve to the project root and tilde should resolve to the nearest node_modules root or project root.

I'm curious about your use case for system-level absolute/tilde paths. We haven't supported that because paths outside of the project are generally not portable between machines.

@jondlm
Copy link
Contributor Author

jondlm commented Aug 10, 2023

Ohh, I totally misunderstood that issue! I didn't realize Parcel had special meanings for those identifiers. I just assumed they were system level and there was a good reason for needing it. I don't actually have a use case here. Just trying to knock off some "help wanted" issues to get comfortable contributing.

I'll rework the PR to properly support the Parcel path semantics. Thanks for the feedback!

@jondlm
Copy link
Contributor Author

jondlm commented Aug 11, 2023

@devongovett I fixed this one up whenever you have a chance to take a look again. Sorry about the initial mixup!

@jondlm jondlm changed the title Add ~ home and absolute path support to the glob resolver Add ~ and / support to the glob resolver Aug 11, 2023
@jondlm
Copy link
Contributor Author

jondlm commented Nov 14, 2023

Thank you @mischnic for cleaning this one up! My apologies for not getting to it :(

@mischnic mischnic merged commit ef83a37 into parcel-bundler:v2 Nov 15, 2023
14 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Glob resolver doesn't support / and ~
4 participants