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: errors in worker handling #7236

Merged
merged 33 commits into from Mar 25, 2022
Merged

Conversation

poyoho
Copy link
Member

@poyoho poyoho commented Mar 9, 2022

Description

classic worker options analyse error and pop importAnalysis plugin in worker bundle

  1. case: ') ... ,' mean no worker options parmas will got a error catch.because commaIndex > endIndex find a error index.
  2. ignore importAnalysis in worker, preLoad is not support in worker(preload method use document). There is no CSS in the worker, so there is no need to load dependencies first and then modules so we can ignore importAnalyseBulld
  3. refactor worker test
  • move the worker in truth dir
  • jestPerTestSetup add <testdir>/config.js to config vite test server
  • add format: es test for worker.
  1. @vite-ignore error message add postion

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

@poyoho poyoho changed the title fix: classic worker options analy fix: classic worker options analyse Mar 9, 2022
@poyoho poyoho changed the title fix: classic worker options analyse fix: classic worker options analyse error and pop importAnalysis plugin in worker bundle Mar 9, 2022
@poyoho poyoho changed the title fix: classic worker options analyse error and pop importAnalysis plugin in worker bundle fix: something error in worker Mar 9, 2022
@@ -306,6 +306,7 @@ export function resolveBuildPlugins(config: ResolvedConfig): {
post: Plugin[]
} {
const options = config.build
const isWorker = config.isWorker
Copy link
Member

@patak-dev patak-dev Mar 9, 2022

Choose a reason for hiding this comment

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

I think we should pass isWorker as a param to resolveBuildPlugins instead. Adding it to the config will make it visible to the final user

Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

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

I'm not 100% sure if removing import analysis for workers is safe, but I have some small suggestions below.

packages/playground/worker/classic-worker.js Outdated Show resolved Hide resolved
packages/vite/src/node/build.ts Outdated Show resolved Hide resolved
@patak-dev
Copy link
Member

@poyoho, @bluwy has a point, we are going to lose import.meta.glob support in workers (we should add a test case for it).

@poyoho poyoho requested review from patak-dev and bluwy March 10, 2022 07:56
@poyoho
Copy link
Member Author

poyoho commented Mar 10, 2022

I update desc

  1. case: ') ... ,' mean no worker options parmas will got a error catch.because commaIndex > endIndex find a error index.
  2. ignore importAnalysis in worker, preLoad is not support in worker(preload method use document). There is no CSS in the worker, so there is no need to load dependencies first and then modules so we can ignore importAnalyseBulld

please cc

@patak-dev @bluwy

@patak-dev patak-dev added the p3-minor-bug An edge case that only affects very specific usage (priority) label Mar 10, 2022
patak-dev
patak-dev previously approved these changes Mar 10, 2022
@patak-dev
Copy link
Member

Looks good to me. I've added it for discussion in the next team meeting due to the new isWorker field in ResolvedConfig. This PR should be merged before releasing 2.9

@patak-dev patak-dev added this to the 2.9 milestone Mar 10, 2022
Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

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

This LGTM too, but will have this discussed in the meeting as mentioned by patak.

Also some minor nitpicks below 😬

packages/playground/worker/index.html Outdated Show resolved Hide resolved
packages/playground/worker/index.html Outdated Show resolved Hide resolved
bluwy
bluwy previously approved these changes Mar 11, 2022
@poyoho
Copy link
Member Author

poyoho commented Mar 16, 2022

@patak-dev @bluwy

There are major changes to the script of the unit test, I don't know if this is good or not, please help to rereview 😘

@poyoho poyoho requested review from patak-dev and bluwy March 23, 2022 02:59
@patak-dev patak-dev changed the title fix: something error in worker fix: errors in worker handling Mar 25, 2022
@patak-dev patak-dev merged commit 77dc1a1 into vitejs:main Mar 25, 2022
@patak-dev
Copy link
Member

We talked today about the PR with the team, it is ok to have isWorker in ResolvedConfig 👍🏼
Thanks again for your work here @poyoho!

@poyoho poyoho deleted the fix/classic-worker branch March 26, 2022 00:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

4 participants