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: broken worker urls in 3rd party modules (fix #10838) #16418
base: main
Are you sure you want to change the base?
fix: broken worker urls in 3rd party modules (fix #10838) #16418
Conversation
Run & review this pull request in StackBlitz Codeflow. |
f6f670f
to
5659f47
Compare
I haven't looked into the original reproduction and the test case here, but would adding When |
@hi-ogawa I have't tried this but from the issue discussion it might have worked for some people. But the problem with this approach is: The library authors don't control the config of the consumer projects. Library authors need to document then for each framework how to integrate and configure the exceptions. Depending on the Frontend Framework used it gets more complex as the vite.config might be hidden from the user. To avoid this complexity it would be good to support this scenario properly in Vite. But I agree that it might be a valid workaround until it is fixed. e.g. Angular requires you to move to a custom builder to specify such things:
|
@Danielku15 Yeah, it's certainly unintuitive (and fair to say it's a bug) when something breaks after the code is moved to Btw, it looks like |
Very good point. The bug description looks very similar to the worker problem. I haven't used these features yet but assuming that that the
Hence it would make sense to put the new |
Description
fixes #10838
As commented in the issues and we can see in the diff the main change is to introduce an additional "fallback file search" for worker files.
3rd party dependencies (from node_modules) will have their bundle output in the vite cache folder.
Situation Before: If this dependency references a worker using the
?module
syntax, Vite derives a wrong file path for the worker which doesn't exist. Later the URL for the worker points to a non-existent file which is never generated. It is treated as optimized dependency.Situation After: We check if the file importing the worker is an optimized dependency, and if yes, we try to resolve the worker file relative to the source of the optimized dependency. This way we jump back into node_modules for the worker file and the normal flow activates.
Checklist:
vite dev
vite build
output.