-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
fix(ssr): hoist export to handle cyclic import better #18983
Open
hi-ogawa
wants to merge
21
commits into
vitejs:main
Choose a base branch
from
hi-ogawa:fix-ssr-transform-hoist-export
base: main
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.
+205
−89
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
5f8c6fd
fix(ssr): hoist export to handle cyclic import better
hi-ogawa b537976
chore: remove override temporarily
hi-ogawa 3cc86da
wip: forget this one too for now
hi-ogawa ed79e4d
wip: workaround cyclic import
hi-ogawa 95f47eb
chore: unused
hi-ogawa 2245aaa
test: fix hmr-ssr
hi-ogawa a8c1d12
Merge branch 'main' into fix-ssr-transform-hoist-export
hi-ogawa c2f7d75
test: fix importing broken entries
hi-ogawa 96f123a
test: tweak
hi-ogawa d5b2333
Merge branch 'main' into fix-ssr-transform-hoist-export
hi-ogawa d252b5c
fix: remove new line
hi-ogawa 7904808
test: update
hi-ogawa 45e74ac
chore: comment
hi-ogawa 83a7a1f
test: test invalid cyclic
hi-ogawa af7de84
chore: comment
hi-ogawa b0b75eb
chore: comment
hi-ogawa 958467a
test: simplify
hi-ogawa 19f7533
test: add test in ssr playground
sapphi-red 059d132
Merge branch 'main' into fix-ssr-transform-hoist-export
hi-ogawa 677949c
test: hacky setupFiles
hi-ogawa a844104
chore: remove unused
hi-ogawa 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 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
22 changes: 22 additions & 0 deletions
22
packages/vite/src/node/ssr/runtime/__tests__/fixtures/cyclic2/README.md
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,22 @@ | ||
- `test1` - `test5` | ||
|
||
Cyclic import example based on https://github.com/vitejs/vite/issues/14048#issuecomment-2354774156 | ||
|
||
```mermaid | ||
flowchart TD | ||
B(dep1.js) -->|dep1| A(index.js) | ||
A -->|dep1| C(dep2.js) | ||
C -->|dep2| A | ||
A -->|dep1, dep2| entry.js | ||
``` | ||
|
||
--- | ||
|
||
- `test6` | ||
|
||
```mermaid | ||
flowchart TD | ||
A(dep1.js) -->|dep1| B | ||
B(dep2.js) -->|dep2| A | ||
A -->|dep1| C(index.js) | ||
``` |
3 changes: 3 additions & 0 deletions
3
packages/vite/src/node/ssr/runtime/__tests__/fixtures/cyclic2/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,3 @@ | ||
{ | ||
"type": "module" | ||
} |
1 change: 1 addition & 0 deletions
1
packages/vite/src/node/ssr/runtime/__tests__/fixtures/cyclic2/test1/dep1.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 const dep1 = { ok: true }; |
2 changes: 2 additions & 0 deletions
2
packages/vite/src/node/ssr/runtime/__tests__/fixtures/cyclic2/test1/dep2.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 { dep1 } from "./index.js" | ||
export const dep2 = { ok: dep1.ok } |
5 changes: 5 additions & 0 deletions
5
packages/vite/src/node/ssr/runtime/__tests__/fixtures/cyclic2/test1/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 { dep1 } from './dep1.js' | ||
export { dep1 } | ||
|
||
import { dep2 } from './dep2.js' | ||
export { dep2 } |
1 change: 1 addition & 0 deletions
1
packages/vite/src/node/ssr/runtime/__tests__/fixtures/cyclic2/test2/dep1.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 const dep1 = { ok: true }; |
2 changes: 2 additions & 0 deletions
2
packages/vite/src/node/ssr/runtime/__tests__/fixtures/cyclic2/test2/dep2.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 { dep1 } from "./index.js" | ||
export const dep2 = { ok: dep1.ok } |
2 changes: 2 additions & 0 deletions
2
packages/vite/src/node/ssr/runtime/__tests__/fixtures/cyclic2/test2/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 @@ | ||
export { dep1 } from './dep1.js' | ||
export { dep2 } from "./dep2.js" |
1 change: 1 addition & 0 deletions
1
packages/vite/src/node/ssr/runtime/__tests__/fixtures/cyclic2/test3/dep1.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 const dep1 = { ok: true }; |
2 changes: 2 additions & 0 deletions
2
packages/vite/src/node/ssr/runtime/__tests__/fixtures/cyclic2/test3/dep2.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 { dep1 } from "./index.js" | ||
export const dep2 = { ok: dep1.ok } |
4 changes: 4 additions & 0 deletions
4
packages/vite/src/node/ssr/runtime/__tests__/fixtures/cyclic2/test3/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,4 @@ | ||
import { dep1 } from './dep1.js' | ||
import { dep2 } from './dep2.js' | ||
export { dep1 } | ||
export { dep2 } |
1 change: 1 addition & 0 deletions
1
packages/vite/src/node/ssr/runtime/__tests__/fixtures/cyclic2/test4/dep1.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 const dep1 = { ok: true }; |
2 changes: 2 additions & 0 deletions
2
packages/vite/src/node/ssr/runtime/__tests__/fixtures/cyclic2/test4/dep2.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 { dep1 } from "./index.js" | ||
export const dep2 = { ok: dep1.ok } |
2 changes: 2 additions & 0 deletions
2
packages/vite/src/node/ssr/runtime/__tests__/fixtures/cyclic2/test4/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 @@ | ||
export * from './dep1.js' | ||
export * from './dep2.js' |
1 change: 1 addition & 0 deletions
1
packages/vite/src/node/ssr/runtime/__tests__/fixtures/cyclic2/test5/dep1.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 const dep1 = { ok: true }; |
2 changes: 2 additions & 0 deletions
2
packages/vite/src/node/ssr/runtime/__tests__/fixtures/cyclic2/test5/dep2.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 { dep1 } from "./index.js" | ||
export const dep2 = { ok: dep1.ok } |
5 changes: 5 additions & 0 deletions
5
packages/vite/src/node/ssr/runtime/__tests__/fixtures/cyclic2/test5/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 { dep2 } from './dep2.js' | ||
export { dep2 } | ||
|
||
import { dep1 } from './dep1.js' | ||
export { dep1 } |
2 changes: 2 additions & 0 deletions
2
packages/vite/src/node/ssr/runtime/__tests__/fixtures/cyclic2/test6/dep1.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 { dep2 } from "./dep2.js" | ||
export const dep1 = "dep1: " + dep2 |
2 changes: 2 additions & 0 deletions
2
packages/vite/src/node/ssr/runtime/__tests__/fixtures/cyclic2/test6/dep2.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 { dep1 } from "./dep1.js" | ||
export const dep2 = "dep2: " + dep1 |
2 changes: 2 additions & 0 deletions
2
packages/vite/src/node/ssr/runtime/__tests__/fixtures/cyclic2/test6/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 { dep1 } from './dep1.js' | ||
export { dep1 } |
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
Oops, something went wrong.
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.
(Just leaving an idea) Maybe we can generate
names
field in the sourcemap.