-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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(legacy): preserve async generator function invocation #15021
Conversation
We can skip Would you add a test for this? I think we can check this by running |
7e5ec40
to
d476721
Compare
d476721
to
c326e1a
Compare
I've added a test for modern chunk legacy guard. |
#14968 (comment) notes that updating the CSP hashes is a breaking change. I'm not sure if we exactly cover that in semver, but the right thing to do seems to be cutting another major? Unfortunately I didn't test that that PR doesn't work in esbuild's minifier either. I'm not really sure what to do at the moment, but thought pointing it out here. |
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 think we can merge this one and release vite-plugin-legacy v6 with it. Even if v5 was released only a week ago, it seems the proper thing to do now.
0e40774
to
fa6d534
Compare
I don't think we should say changing the hash is a breaking change. Otherwise, we'll have to bump majors every time the inline script is changed. That will make it difficult to release a bug fix in minor/patches. I wonder if we should remove the actual value from the README and show the command to obtain the values instead and clarify the value might change in patches. |
@lsdsjy Would you remove the
Good catch! Thanks! |
@sapphi-red There're 2 ways to preserve the invocation of the async generator function:
I'm taking the first approach here. I can switch to approach 2 but I'm not sure because I think the first one is clearer because these three parallel statements make it immediately apparent that they involve three language features( |
Ah, my bad, I was misunderstanding it. |
It is technically a breaking change, as it will require a change to work for certain users. I think it isn't a problem that it is in the readme, but it isn't clear when users need to change these. I think it could be valid for us to say that we'll only release changes to these hashes in minors (if we want to avoid major releases), with a note in that section. Users with a strict policy could then set the range to the current minor and still get other patches. |
Description
This PR is a continuation of #14968, whose trick works perfectly fine on older versions of vite but fails on vite@>4.4.0 because of the version bump of
esbuild
to 0.18.2.esbuild@0.18.2
introduces pure annotations for iife expressions, so the annotated async generator function will be dropped (by minifiers I think).Additional context
A shorter way to preserve the generator function here is:
I don't know if that is enough for syntax detecting since the body won't be executed until
.next()
is called.What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).