-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support monorepo package self-references (vercel/turborepo#8820)
Closes PACK-3107 Packages importing themselves works fine for packages from npm, since they always live at `.../node_modules/foo` anyway and so the regular node_modules resolution covers self-references as well. This is not the case for (symlinked) monorepo workspaces, which this PR fixes. This essentially adds the `LOAD_PACKAGE_SELF` step from https://nodejs.org/api/modules.html#all-together .
- Loading branch information
Showing
4 changed files
with
71 additions
and
3 deletions.
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/execution/turbopack/resolving/self-reference/input/env-entry.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 123; |
5 changes: 5 additions & 0 deletions
5
crates/turbopack-tests/tests/execution/turbopack/resolving/self-reference/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,5 @@ | ||
import env from "self-reference/env"; | ||
|
||
it("should allow self-referencing imports using the exports field", () => { | ||
expect(env).toBe(123); | ||
}); |
9 changes: 9 additions & 0 deletions
9
crates/turbopack-tests/tests/execution/turbopack/resolving/self-reference/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,9 @@ | ||
{ | ||
"name": "self-reference", | ||
"version": "0.0.0", | ||
"exports": { | ||
"./env": { | ||
"default": "./env-entry.js" | ||
} | ||
} | ||
} |