-
Notifications
You must be signed in to change notification settings - Fork 27.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug with
imports
field from a nested directory (vercel/turborep…
…o#5366) ### Description When importing a `#foo` subpath import, the resolved file is relative the the `package.json` containing the `imports` field, not the file with the import statement. This fixes subpath imports to use the proper context path during that resolve. ### Testing Instructions ``` RUST_BACKTRACE=1 cargo nextest run -p turbopack-tests -E 'test(snapshot__imports__subpath_imports_nested)' --no-capture ``` Fixes WEB-1216
- Loading branch information
1 parent
c06f012
commit cb11292
Showing
10 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
crates/turbopack-tests/tests/snapshot/imports/subpath-imports-nested/input/foo.js
This file contains 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 "foo"; |
3 changes: 3 additions & 0 deletions
3
crates/turbopack-tests/tests/snapshot/imports/subpath-imports-nested/input/index.js
This file contains 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,3 @@ | ||
import foo from "./nested"; | ||
|
||
console.log(foo); |
2 changes: 2 additions & 0 deletions
2
crates/turbopack-tests/tests/snapshot/imports/subpath-imports-nested/input/nested/index.js
This file contains 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,2 @@ | ||
import foo from "#foo"; | ||
export default foo; |
6 changes: 6 additions & 0 deletions
6
crates/turbopack-tests/tests/snapshot/imports/subpath-imports-nested/input/package.json
This file contains 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 @@ | ||
{ | ||
"name": "subpath-imports", | ||
"imports": { | ||
"#foo": "./foo.js" | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...s-nested/output/a587c_tests_snapshot_imports_subpath-imports-nested_input_index_5771e1.js
This file contains 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 @@ | ||
(globalThis.TURBOPACK = globalThis.TURBOPACK || []).push([ | ||
"output/a587c_tests_snapshot_imports_subpath-imports-nested_input_index_5771e1.js", | ||
{}, | ||
]); | ||
(globalThis.TURBOPACK_CHUNK_LISTS = globalThis.TURBOPACK_CHUNK_LISTS || []).push({ | ||
"path": "output/a587c_tests_snapshot_imports_subpath-imports-nested_input_index_5771e1.js", | ||
"chunks": [ | ||
"output/a587c_tests_snapshot_imports_subpath-imports-nested_input_index_b53fce.js" | ||
], | ||
"source": "entry" | ||
}); |
32 changes: 32 additions & 0 deletions
32
...s-nested/output/a587c_tests_snapshot_imports_subpath-imports-nested_input_index_b53fce.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
...sted/output/a587c_tests_snapshot_imports_subpath-imports-nested_input_index_b53fce.js.map
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
...s-nested/output/a587c_tests_snapshot_imports_subpath-imports-nested_input_index_dc7802.js
This file contains 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 @@ | ||
(globalThis.TURBOPACK = globalThis.TURBOPACK || []).push([ | ||
"output/a587c_tests_snapshot_imports_subpath-imports-nested_input_index_dc7802.js", | ||
{}, | ||
{"otherChunks":[{"path":"output/a587c_tests_snapshot_imports_subpath-imports-nested_input_index_b53fce.js","included":["[project]/crates/turbopack-tests/tests/snapshot/imports/subpath-imports-nested/input/index.js (ecmascript)"]}],"runtimeModuleIds":["[project]/crates/turbopack-tests/tests/snapshot/imports/subpath-imports-nested/input/index.js (ecmascript)"]} | ||
]); | ||
// Dummy runtime |
4 changes: 4 additions & 0 deletions
4
...sted/output/a587c_tests_snapshot_imports_subpath-imports-nested_input_index_dc7802.js.map
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.