Skip to content

fix: keep nested worker assets live across tree-shaken main refs - #23899

Open
FelixFangX wants to merge 1 commit into
vitejs:mainfrom
FelixFangX:fix/nested-worker-tree-shaken-emit
Open

FelixFangX wants to merge 1 commit into
vitejs:mainfrom
FelixFangX:fix/nested-worker-tree-shaken-emit

Conversation

@FelixFangX

@FelixFangX FelixFangX commented Oct 26, 2026 •

Copy link
Copy Markdown

Description

Nested workers were dropped from dist/ when their starter module was also present in the client graph and got tree-shaken there, while an outer worker still needed them. Cleanup treated the nested worker as dead after the main-graph reference vanished, even though another live worker still referenced the helper asset.

This keeps transitively live worker assets when filtering dead references in both main and worker builds, and adds a regression fixture matching the #23894 shape.

Fixes #23894

Additional context

Reproduced with the issue gist on Vite 8.3.5 (helper-*.js missing). After this change, the same gist against a local build reports OK: nested worker emitted. Related nearby work: #23848 / #23874 (nested worker caching).

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.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • 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).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@FelixFangX
FelixFangX force-pushed the fix/nested-worker-tree-shaken-emit branch 2 times, most recently from 18f1250 to 86f7a14 Compare October 27, 2026 08:09
When a nested worker's starter module is tree-shaken from the client
graph but still used by an outer worker, cleanup was deleting the
helper asset. Preserve transitively live worker assets in both main
and worker builds.

Fixes vitejs#23894
@FelixFangX
FelixFangX force-pushed the fix/nested-worker-tree-shaken-emit branch from 86f7a14 to c611154 Compare October 27, 2026 13:28

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nested worker not emitted when its module is tree-shaken from the main bundle (regression in 8.3.0-beta.0)

1 participant