-
-
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): crash on circular import #14441
Conversation
Run & review this pull request in StackBlitz Codeflow. |
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.
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.
LGTM! I think there is an unresolved nit regarding types of defineImport
Co-authored-by: Bjorn Lu <[email protected]>
I think this PR can be merged first |
/ecosystem-ci run |
📝 Ran ecosystem CI: Open
|
Besides nx which seems to take too long to test, the rest seems to match |
How did you find out about this? I want to do my part for this. |
In the I'm not exactly sure how to fix it but thanks for helping with this. |
export function getB() { | ||
return '__B__' | ||
} | ||
|
||
export { A } from './a' |
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.
export function getB() { | |
return '__B__' | |
} | |
export { A } from './a' | |
export { A } from './a' | |
export function getB() { | |
return '__B__' | |
} |
If I change this file like above, the test fails with getB is not a function
. But this code should also work as it works if I run it with node ./playground/ssr/src/circular-import/index.js
(the .js
extension needs to be appended to imports).
I guess while this PR fixes in some cases, it breaks in some cases.
I don't know a way to fix this completely but I feel I definitely need to read https://262.ecma-international.org/14.0/#sec-example-cyclic-module-record-graphs
related: #14048 (comment)
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.
Good catch. Yes, It's a little tricky to fix completely. I'm guessing it would need to be in two phases as you said in #14048 (comment)
For this PR, I think the current import/export order is more intuitive.
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.
I've discussed this with Sapphi. While we'd like this fix too, the current PR does improves some areas with circular imports and doesn't regress this case (getB is not a function
would also happen in main
). So we can defer this to later and get this PR merged for now.
Putting this out of 5.0 milestone for now as this fix could be done in a patch in the future. We're trying to scope down the milestone to release on time. |
What time for release 5.0? |
The schedule now is by the end of the month, so trying to finish up all of those in the milestone while having enough time for user testing. |
Thanks to the vite team for all their hard work and I can't wait for the release of vite 5! |
Hello, any info about this issue? https://github.com/lysekjan/vitest-imports Versionvitest 1.0.4 |
Description
An interesting bug, I stumbled upon
ssrTransform
changing the order of import/export. Yes! This problem is essentially caused by a change in the order ofimport/export
.But I'm not sure it's completely fixed.
Fixes: #14433
Fixes: #14010
Additional context
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).