fix(compiler): silence INVALID_ANNOTATION and SOURCEMAP_BROKEN warnings from workerPlugin#6718
Merged
johnjenkins merged 2 commits intoMay 13, 2026
Conversation
added 2 commits
May 13, 2026 15:15
The /*@__PURE__*/ annotation is only meaningful in front of call or new expressions. In getWorkerMain and getInlineWorker it was placed before an import.meta.ROLLUP_FILE_URL_* property access, which Rollup cannot interpret and silently strips with an INVALID_ANNOTATION warning on every build of a project that uses *.worker.ts entries. Drop the unused annotation on the workerPath assignment. The remaining PURE markers on the createWorker(...) / createWorkerProxy(...) calls are unchanged.
The workerPlugin transform hook returned synthetic wrapper code without a sourcemap, triggering a SOURCEMAP_BROKEN warning from Rollup for every project that builds a *.worker.ts entry. The Rollup plugin convention for transforms that produce code with no useful source-position mapping is to return an empty mappings string; do that for all five transform return paths (the mocked hydrate/worker-platform branch and the four real-bundle branches).
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses persistent Rollup bundling warnings emitted whenever a project bundles *.worker.ts / *.worker.tsx entries, by fixing the warning sources inside the internal workerPlugin implementation.
Changes:
- Remove invalid
/*@__PURE__*/annotations that were placed onimport.meta.ROLLUP_FILE_URL_*property access, which triggers Rollup’sINVALID_ANNOTATIONwarning. - Return an explicit empty sourcemap (
map: { mappings: '' }) from alltransformpaths that generate synthetic wrapper modules, silencingSOURCEMAP_BROKEN.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the current behavior?
Every project that bundles a
*.worker.ts(or*.worker.tsx) entry emits two bundling warnings on every build:The
SOURCEMAP_BROKENvariant has been tracked as a validated bug for over three years (#3476, opened against v2.17.1, labelsBug: Validated,Help Wanted). A minimal reproduction repo is linked from that issue: https://github.com/Scan0815/stencil-source-map-error. Both warnings originate fromsrc/compiler/bundle/worker-plugin.ts. There is no user-facing way to suppress them:validateRollupConfig(src/compiler/config/validate-rollup-config.ts) whitelists onlycontext,moduleContext,treeshake,external,maxParallelFileOpsfromrollupConfig.inputOptions, so anonwarnoverride onstencil.config.tsis dropped before reaching Rollup. The hardcodedignoreWarnCodesset insrc/utils/logger/logger-rollup.tsdoes not include either code.Fixes #3476
What is the new behavior?
Two independent fixes in
src/compiler/bundle/worker-plugin.ts:1.
INVALID_ANNOTATION—/*@__PURE__*/is meaningful only in front of call ornewexpressions. IngetWorkerMainandgetInlineWorkerthe marker was placed in front ofimport.meta.ROLLUP_FILE_URL_*, a property access. Rollup cannot apply pure-side-effect analysis there and strips the comment with the warning above. The two stale markers onworkerPathare removed. The remaining/*@__PURE__*/markers on the actualcreateWorker(...)/createWorkerProxy(...)calls are unchanged and still effective.2.
SOURCEMAP_BROKEN(#3476) — thetransformhook returned synthetic wrapper code without a sourcemap. The Rollup plugin convention for transforms that produce code with no useful source-position mapping is to returnmap: { mappings: '' }. All fivetransformreturn paths now do so: the mocked hydrate/worker-platform branch and the four real-bundle branches (?worker,?worker-inline, proxy + inline-proxy).Neither change alters runtime behavior. The two commits are kept separate so each fix is independently revertable.
Documentation
N/A — no public API surface change.
Does this introduce a breaking change?
Testing
npx tsc --noEmitpasses after each commit.src/compiler/bundle/worker-plugin.ts(a pre-existingsimple-import-sort/importsfinding onmainis left untouched to keep this PR focused).npm run build) and end-to-end verification against the bug: Bundling Warning SOURCEMAP_BROKEN if web-worker is used #3476 reproduction repo have not been performed locally and are deferred to CI / reviewer verification. Steps to reproduce remain those in the original issue.Other information
The two affected helpers (
getWorkerMain,getInlineWorker) and the fourtransformreturn branches were unchanged in behavior across recent history, so this is purely a hygiene fix on long-standing output. Disclosure: I'm the original reporter of #3476.