-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fallback to normal resolving if alias doesn't resolve (#7778)
### Description fixes vercel/next.js#62037 ### Testing Instructions <!-- Give a quick description of steps to test your changes. --> Closes PACK-2800
- Loading branch information
Showing
9 changed files
with
44 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
24 changes: 24 additions & 0 deletions
24
crates/turbopack-tests/tests/execution/turbopack/resolving/tsconfig-fallback/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,24 @@ | ||
import foo from "@foo"; | ||
import fooBar from "@foo/bar"; | ||
import bazFoo from "@baz/foo"; | ||
import srcBazFoo from "@src/baz/foo"; | ||
|
||
it("should resolve an alias to a local file", () => { | ||
expect(foo).toBe("foo"); | ||
expect(require("@foo")).toHaveProperty("default", "foo"); | ||
}); | ||
|
||
it("should fallback from an alias", () => { | ||
expect(fooBar).toBe("@foo/bar"); | ||
expect(require("@foo/bar")).toHaveProperty("default", "@foo/bar"); | ||
}); | ||
|
||
it("should prefer alias over normal resolving", () => { | ||
expect(bazFoo).toBe("baz/foo"); | ||
expect(require("@baz/foo")).toHaveProperty("default", "baz/foo"); | ||
}); | ||
|
||
it("should resolve the alternative alias value", () => { | ||
expect(srcBazFoo).toBe("baz/foo"); | ||
expect(require("@src/baz/foo")).toHaveProperty("default", "baz/foo"); | ||
}); |
1 change: 1 addition & 0 deletions
1
...ests/execution/turbopack/resolving/tsconfig-fallback/input/node_modules/@baz/foo/index.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
.../execution/turbopack/resolving/tsconfig-fallback/input/node_modules/@baz/foo/package.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
...ests/execution/turbopack/resolving/tsconfig-fallback/input/node_modules/@foo/bar/index.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
.../execution/turbopack/resolving/tsconfig-fallback/input/node_modules/@foo/bar/package.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
...urbopack-tests/tests/execution/turbopack/resolving/tsconfig-fallback/input/src/baz/foo.ts
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 "baz/foo"; |
1 change: 1 addition & 0 deletions
1
...es/turbopack-tests/tests/execution/turbopack/resolving/tsconfig-fallback/input/src/foo.ts
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"; |
7 changes: 7 additions & 0 deletions
7
...turbopack-tests/tests/execution/turbopack/resolving/tsconfig-fallback/input/tsconfig.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,7 @@ | ||
{ | ||
"compilerOptions": { | ||
"paths": { | ||
"@*": ["./src/*", "./*"] | ||
} | ||
} | ||
} |