-
Notifications
You must be signed in to change notification settings - Fork 30.3k
Turbopack: Resolve aliases from import location for transitive deps #88880
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
base: canary
Are you sure you want to change the base?
Conversation
When resolveAlias is configured, the alias is currently resolved from project_path instead of from the original import location. This can cause issues when transitive dependencies try to import the aliased package, because the package might only exist in the transitive dependency's `node_modules`, not in the project root's `node_modules`. The bug was introduced in commit f8cd413. The intent there was to add support for conditional aliases, but it also changed the resolution base from the import site to the project root, which causes this issue. Use None for the lookup path, which allows the resolver to use the original import location. This means: - Direct dependencies continue to work (resolution happens from project root) - Transitive dependencies now work (resolution happens from their location) Fixes: vercel#88540
|
Allow CI Workflow Run
Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer |
2 similar comments
|
Allow CI Workflow Run
Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer |
|
Allow CI Workflow Run
Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer |
CodSpeed Performance ReportMerging this PR will not alter performanceComparing Summary
Footnotes
|
|
"It's not a bug, it's a feature" yeah, but actually it's intentionally resolving from the project root. You write the request in the next.config, so it should resolve from there. That's quite important e. g. for relative requests: But there are usecases where you want to resolve from the original location. We discussed that before and that makes sense, but it should be opt-in. Maybe: |
|
Thanks for coming back! The reasoning for relative paths makes sense, a couple of clarifying questions:
I am not super familiar with Turbopack and am trying to put in some PRs to get more familiar and spelunk around the codebase, so it's possible that I am missing some historical context here :-) |
When resolveAlias is configured, the alias is currently resolved from project_path instead of from the original import location. This can cause issues when transitive dependencies try to import the aliased package, because the package might only exist in the transitive dependency's
node_modules, not in the project root'snode_modules.The bug was introduced in commit f8cd413. The intent there was to add support for conditional aliases, but it also changed the resolution base from the import site to the project root, which causes this issue.
Use None for the lookup path, which allows the resolver to use the original import location. This means:
Fixes: #88540