Skip to content
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(worker): throw error when circular worker import is detected and support self referencing worker #16103

Merged
merged 3 commits into from
Mar 6, 2024

Conversation

sapphi-red
Copy link
Member

@sapphi-red sapphi-red commented Mar 6, 2024

Description

The first commit makes Vite to throw an error when a circular worker import is detected.
The second and third commits adds support for simple circular import cases (self reference).

fixes #7015

I didn't add support for complex cases (e.g. worker-a.js has import 'worker-b.js?worker' and worker-b.js has import 'worker-a.js?worker'). For those cases, Vite now throw errors (before this PR, the build never finished). But I think it's fine because doing that is not popular and will make the code complex. I checked that supporting the simple cases makes the build of #7015, #7015 (comment), #12755, #14499, #15288, #15426, jamsinclair/jSquash#15 pass.

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines, especially the Pull Request Guidelines.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Update the corresponding documentation if needed.
  • Ideally, include relevant tests that fail without this PR but pass with it.

@sapphi-red sapphi-red added p3-minor-bug An edge case that only affects very specific usage (priority) feat: web workers labels Mar 6, 2024
Copy link

stackblitz bot commented Mar 6, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@sapphi-red sapphi-red added the inconsistency Inconsistency between dev & build label Mar 6, 2024
@patak-dev
Copy link
Member

/ecosystem-ci run

@patak-dev
Copy link
Member

Awesome! Feel free to merge this one if you'd like to see it in a patch. If not, I'll wait for 5.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat: web workers inconsistency Inconsistency between dev & build p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Importing a file from a web worker that imports said web worker causes Vite to build forever
2 participants