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): replace import.meta correctly for IIFE worker #15321

Merged
merged 4 commits into from
Dec 12, 2023

Conversation

XiSenao
Copy link
Collaborator

@XiSenao XiSenao commented Dec 12, 2023

Description

fix #15310
fix #15305
refs #12629

Additional context

We may also need to compile import.meta to avoid errors when using it directly in worker. this modification is consistent with the development environment, and import.meta only exposes the url property.


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.

Copy link

stackblitz bot commented Dec 12, 2023

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

@XiSenao XiSenao changed the title fix: import.meta compilation error fix: import.meta compiles abnormally in worker Dec 12, 2023
@XiSenao XiSenao force-pushed the fix/import-meta-compilation-error branch from 65d033d to 4c40667 Compare December 12, 2023 01:34
@XiSenao XiSenao force-pushed the fix/import-meta-compilation-error branch from 4c40667 to a00f6f6 Compare December 12, 2023 01:45
@XiSenao
Copy link
Collaborator Author

XiSenao commented Dec 12, 2023

It seems that the behavior of recent test has become strange.

@sapphi-red sapphi-red added p3-minor-bug An edge case that only affects very specific usage (priority) feat: web workers labels Dec 12, 2023
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.

Thanks! Would you add a test?

packages/vite/src/node/plugins/worker.ts Show resolved Hide resolved
@sapphi-red
Copy link
Member

It seems that the behavior of recent test has become strange.

Yeah, it seems quite flaky.

@sapphi-red sapphi-red changed the title fix: import.meta compiles abnormally in worker fix(worker): replace import.meta correctly for IIFE worker Dec 12, 2023
@XiSenao
Copy link
Collaborator Author

XiSenao commented Dec 12, 2023

Thanks! Would you add a test?

Yeah, I can provide test cases.

@patak-dev patak-dev merged commit 08d093c into vitejs:main Dec 12, 2023
10 checks passed
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)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Abnormal behaviors in building worker modules. "ReferenceError: document is not defined" in worker
3 participants