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(plugin-legacy): fix legacy plugin not working in worker context #19079

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sapenlei
Copy link
Contributor

closes #19073

Copy link
Member

@sapphi-red sapphi-red left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is correct. The worker entry chunks are not legacy chunks.

@sapphi-red sapphi-red added plugin: legacy p3-minor-bug An edge case that only affects very specific usage (priority) feat: web workers labels Dec 27, 2024
@sapenlei
Copy link
Contributor Author

I don't think this is correct. The worker entry chunks are not legacy chunks.

Okay, I'll change it.

Copy link
Member

@sapphi-red sapphi-red left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this change will make the build application error in runtime because the legacy plugin does not transpile the worker content. I think we need to

  1. show an warning if a worker is used when legacy chunks are generated
  2. [optional] avoid injecting __vite_legacy_guard to worker chunks so that workers work in that case

The ideal fix is to generate legacy chunks for workers. But that's hard to do.

@sapenlei
Copy link
Contributor Author

sapenlei commented Jan 7, 2025

CleanShot 2025-01-07 at 16 25 31@2x
It's because when iife format,esbuild doesn't convert, I think I changed it correctly and tested it locally with no problems! 😭 @sapphi-red

@sapenlei
Copy link
Contributor Author

sapenlei commented Jan 7, 2025

CleanShot 2025-01-07 at 16 31 21@2x
So when it's a worker and it's in iife format, esbuild converts the iife

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

Successfully merging this pull request may close these issues.

Unable to package normal files in web worker
2 participants