-
-
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
feat: cancellable scan during optimization #12225
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.
This looks pretty good to me!
I don't see this as a fix for #9986. If it helps, it is on hiding a race condition we should still work out.
Yeah, you're right, I realized that as well. This is just for the scan phase. We'd need to do the same thing for the actual optimization phase which is where #9986 is occurring
@@ -48,8 +48,11 @@ export const importsRE = | |||
/(?<!\/\/.*)(?<=^|;|\*\/)\s*import(?!\s+type)(?:[\w*{}\n\r\t, ]+from)?\s*("[^"]+"|'[^']+')\s*(?=$|;|\/\/|\/\*)/gm | |||
|
|||
export async function scanImports(config: ResolvedConfig): Promise<{ |
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.
Is the return type right here? It looks like its returning { cancel, result }
and not Promise<{ cancel, result }>
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 was following @dominikg's PR here. The esbuildContext
is only available after waiting for other async operations. But I agree that from a consumer POV, it is better to avoid the double promise, vitejs/vite@5ff8d8b
(#12225) avoids this at the expense of a bit more complexity inside scanImports
I'll check this in another PR. What I'm thinking though is that we could avoid naming all temporal folders in the same way. That is forcing us to be very careful about serializing optimizer runs. We can add a unique key per run, so it will be |
We would need a way to clean up residue though. Even today sometimes temporary vite config bundle files remain on disk if the process terminates at the wrong point in time. It would be worse when the same was true for optimizer output. |
To clean up, we could delete anything beginning with |
needs to ensure that there isn't another server currently having a go at it. Having 2 running on the same setup at the same time was something that came up lately and with optimize on build and parallel builds it might apply there too. |
one way to do it would be to check if the folder is more than 1 day old then it's safe to delete or something like that |
Co-authored-by: Ben McCann <[email protected]>
Closes #11243
Co-authored-by: dominikg
Description
This is a rework of #11243 using esbuild added support for canceling builds.
I don't see this as a fix for #9986. If it helps, it is on hiding a race condition we should still work out.
What is the purpose of this pull request?