-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
docs: add warning on Worker import with constructor limitations #15436
Merged
Conversation
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
Run & review this pull request in StackBlitz Codeflow. |
malta895
commented
Dec 27, 2023
malta895
commented
Dec 27, 2023
malta895
changed the title
fix: warning on new Worker limitations
fix: warning on Worker import with constructor limitations
Dec 27, 2023
rubiin
approved these changes
Dec 27, 2023
malta895
commented
Dec 27, 2023
malta895
commented
Dec 28, 2023
bluwy
changed the title
fix: warning on Worker import with constructor limitations
docs: add warning on Worker import with constructor limitations
Jan 8, 2024
patak-dev
reviewed
Jan 8, 2024
Co-authored-by: patak <matias.capeletto@gmail.com>
patak-dev
approved these changes
Jan 8, 2024
sapphi-red
approved these changes
Jan 26, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
The explanation on how to import Workers with Constructor is not explaining how Vite actually parses the user code at build time.
I tried to import a
SharedWorker
like this:This isn't working for two reasons:
name
option isn't a static value, and it triggers a build errorworkerUrl
is declared in a separated variable, and this is not recognized by ViteThe latter does not even trigger an error, but just a warning. This ends up in a potentially broken build, without the Worker being bundled correctly.
Reference to the relevant code: https://github.com/vitejs/vite/blob/56ae92c33cba6c86ab5819877c19b9ea39f7121b/packages/vite/src/node/plugins/workerImportMetaUrl.ts
I added a warning that explains this behavior.
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).