-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
feat(import-glob): support read module from alias pattern #12221
base: main
Are you sure you want to change the base?
Conversation
Run & review this pull request in StackBlitz Codeflow. |
2d5c458
to
302b068
Compare
Can you help review this pr ? @bluwy @sapphi-red Thanks. |
After this PR, the resulting obj from
We could only include the aliased path but I think this may be more confusing that the current behavior. Maybe what we need here is to update the docs to be explicit about an aliased path in glob returning absolute paths? |
Yeah, it will have duplicated entries for each |
Having both isn't possible because then users would need to de-duplicate them. Imagine if they do a glob and iterate over the result to do something with each. So if we change something, I think the paths could keep the alias instead of using absolute paths. But I don't know how much ergononic is to have the unresolved path as the key instead of the absolute path here. cc @brillout @antfu, interested in your opinion here. |
I think we should preserve the path format. In other words:
The pro here is that the user has the flexibility to choose the format. And, AFAICT, I don't see any drawback for this. I believe that's what we decided back in the days of
Agreed.
I think so too.
If the user wishes to have absolute paths, then he can provide an absolute glob path instead of an aliased one. |
I've been thinking of a solution for this, I feel like the current behaviour while strange is able to scale to more cases. For example, import.meta.glob(['@/data/*.json', '!@/data/draft.json', './extras/*.json']) It would be hard to determine what the keys should be. Some will have aliases, some will not. Today, the keys for this is The keys are root-relative if one of the globs are not relative. So to summarize and document how it works today:
If we want to change something, I think we need to add compat keys to prevent a big breaking change, maybe through a Proxy. But in this case, I think documenting it should be enough. |
I'll move this off the Vite 5 milestone for now. From the above comment, we could start with a documentation update. If we want to change the behaviour, we might need to plan out a migration path and some sort of compat so it doesn't cause a big breaking change. |
Description
refs #12180
Additional context
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).