-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Turbopack: fix strip_prefix prefix is too long
#84969
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
Draft
mischnic
wants to merge
4
commits into
canary
Choose a base branch
from
mischnic/stripprefix-too-long
base: canary
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import(`@/${globalThis.type}/${globalThis.processedSlugPath}`) | ||
|
||
// globalThis.docs = 'docs' | ||
// console.trace(require(`@/${globalThis.docs}/foo`)) | ||
|
||
// globalThis.foo = 'foo' | ||
// console.trace(require(`@/docs/${globalThis.foo}`)) | ||
|
||
export default function page() { | ||
return <div>hello</div> | ||
} |
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default 'docs' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default 'docs2' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/// <reference types="next" /> | ||
/// <reference types="next/image-types/global" /> | ||
import './.next/types/routes.d.ts' | ||
|
||
// NOTE: This file should not be edited | ||
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information. |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2022", | ||
"lib": ["dom", "dom.iterable", "esnext"], | ||
"allowJs": true, | ||
"skipLibCheck": true, | ||
"strict": true, | ||
"noEmit": true, | ||
"esModuleInterop": true, | ||
"module": "esnext", | ||
"moduleResolution": "bundler", | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"jsx": "react-jsx", | ||
"incremental": true, | ||
"plugins": [ | ||
{ | ||
"name": "next" | ||
} | ||
], | ||
"paths": { | ||
"@/*": ["./*"], | ||
"@/docs/*": ["./docs2/*"] | ||
}, | ||
"strictNullChecks": true | ||
}, | ||
"include": [ | ||
"**/*.mts", | ||
"**/*.ts", | ||
"**/*.tsx", | ||
".next/types/**/*.ts", | ||
"next-env.d.ts", | ||
"next.config.mjs", | ||
".next/dev/types/**/*.ts" | ||
], | ||
"exclude": ["node_modules", "**/*.test.ts", "**/*.test.tsx"] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 11 additions & 3 deletions
14
...turbopack-tests/tests/execution/turbopack/resolving/tsconfig-paths-dynamic/input/index.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...rbopack-tests/tests/execution/turbopack/resolving/tsconfig-paths-dynamic/input/src/foo.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...ts/tests/execution/turbopack/resolving/tsconfig-paths-dynamic/input/sub-override/file1.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default 'file1-override' |
1 change: 1 addition & 0 deletions
1
...ts/tests/execution/turbopack/resolving/tsconfig-paths-dynamic/input/sub-override/file2.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default 'file2-override' |
1 change: 1 addition & 0 deletions
1
...ts/tests/execution/turbopack/resolving/tsconfig-paths-dynamic/input/sub-override/file3.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default 'file3-override' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
An error message has been simplified, losing valuable diagnostic information that was in the original code.
View Details
Analysis
Error message loses diagnostic information in Pattern::strip_constant_prefix_len()
What fails: The error message at line 282 in
turbopack/crates/turbopack-core/src/resolve/pattern.rs
when callingstrip_constant_prefix_len()
on a Dynamic or DynamicNoSlash pattern no longer includes thelen
value or the pattern description.How to trigger it:
Result: Error message:
"strip_constant_prefix_len prefix is too long"
(generic, no context about the length or pattern)Expected: Error message should include diagnostic details like in commit c6a6c73 (#84882):
This provides developers with the actual
len
value that exceeded the limit and the pattern description, which are valuable for debugging path resolution failures. The enhanced error message was intentionally added in commit c6a6c73 ("Turbopack: better errors for strip_prefix_len") with the message "To help debugging", but was removed in a subsequent WIP commit.While some callers (in
alias_map.rs
) wrap the error with additional context, not all callers do (e.g.,typescript.rs
), so the function should include these diagnostic details in its own error message for complete debugging information across all call sites.