-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Lookup alias and import maps using Pattern instead of String #8852
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
8 Skipped Deployments
|
🟢 Turbopack Benchmark CI successful 🟢Thanks |
✅ This change can build |
|
dd8d510
to
cdf9cf7
Compare
cdf9cf7
to
5e13760
Compare
74e54a0
to
5c0005f
Compare
5c0005f
to
4d7072a
Compare
4d7072a
to
c4e171e
Compare
So now the output of const messages = await import(`@/messages/${locale}.json`); is const messages = await __turbopack_module_context__({
"./messages/de.json": {
id: ()=>"[project]/messages/de.json (json, async loader)",
module: ()=>__turbopack_require__("[project]/messages/de.json (json, async loader)")(__turbopack_import__)
},
"./messages/en.json": {
id: ()=>"[project]/messages/en.json (json, async loader)",
module: ()=>__turbopack_require__("[project]/messages/en.json (json, async loader)")(__turbopack_import__)
}
}).import(`@/messages/${locale}.json`) which fails because But apart from that, this PR is ready |
let common_prefixes = self.map.common_prefixes(request.as_bytes()); | ||
let common_prefixes = self | ||
.map | ||
.common_prefixes(request.constant_prefix().as_bytes()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will lead to also returning non-matching results. e. g. Pattern could be "a" | "b"
which has no constant_prefix so it would return "c"
too.
You probably want:
- Do multiple lookups internally when you have Alternatives
- Filter the results by matching with the Pattern
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this doesn't happen, map.common_prefixes("")
is just empty. That does align with example on https://docs.rs/patricia_tree/latest/patricia_tree/map/type.PatriciaMap.html#method.common_prefixes
But still, map.lookup(Pattern::Alternative(...))
currently never returns anything even if some/all alternatives match. And even then, just returning enum AliasMatch<R> {Exact(R), Replaced(R)}
is wrong anyway because some might be exact and some might be replaced matches
let common_prefixes = self.map.common_prefixes(request.as_bytes()); | ||
let common_prefixes = self | ||
.map | ||
.common_prefixes(request.constant_prefix().as_bytes()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
Including vercel/turborepo#8852 Fixes #63372 Fixes PACK-2801 - [x] Change `RequestKey` handling: vercel/turborepo#8852 (comment) - [x] Fix lookup for alternatives: vercel/turborepo#8852 (comment)
The changes I had to make got out of hand quite quickly, because operating on
Pattern
s everywhere is more cumbersome than strings...Furthermore, some structs contained strings (but unrelated to requests being treated as strings, rather because import maps are specified as strings with wildcards), so now we needed a version with patterns.
This is almost working, namely the dynamic
@/*
alias is already rewritten correctly now:Closes PACK-2801
Related to vercel/next.js#63372