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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(worker): disable manifest plugins in worker build #12661

Merged
merged 1 commit into from Mar 30, 2023

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented Mar 30, 2023

Description

When building worker files with Vite plugins, disable the manifest plugins as workers don't need a manifest file. Otherwise the manifest gets emitted into the main Vite build bundle here:

generateBundle(opts) {
// @ts-expect-error asset emits are skipped in legacy bundle
if (opts.__vite_skip_asset_emit__ || isWorker) {
return
}
const workerMap = workerCache.get(config)!
workerMap.assets.forEach((asset) => {
this.emitFile(asset)
workerMap.assets.delete(asset.fileName!)
})
},

So when the actual manifest plugin on the main build runs, you would get this warning from Rollup:

The emitted file "manifest.json" overwrites a previously emitted file of the same name.

Additional context

In most case, this is harmless, but there seems to be an fs race condition where the worker manifest gets written down in a SvelteKit build 馃

It isn't easy to write a test for this too, the logs come from Rollup, and we don't have a setup to track Rollup logs.


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 PR Title 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.

@stackblitz
Copy link

stackblitz bot commented Mar 30, 2023

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

@bluwy bluwy added p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority) feat: web workers labels Mar 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat: web workers p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants