fix(data-testing): mark conformance-case calls @__PURE__ so unused fixtures tree-shake - #185
Merged
Conversation
…s @__PURE__ so unused fixtures tree-shake An unused `cases` export whose initializer is an unannotated function call (`Conformance.cases(fn, ...)`) is kept by Rollup/esbuild even when the transition `fn` it sits beside is genuinely imported elsewhere — the package's `sideEffects: false` only elides unused *imports*, not this call. Verified against a real Vite production build: the case-fixture data and builder logic shipped without the annotation, and were fully eliminated with it. Annotates all 34 existing call sites across the reference apps, corrects the misleading comment in data-testing's index.ts, and updates the data-ai guidance to require the annotation on every future Conformance.cases/derivations call. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Summary
casesexport (export const cases = Conformance.cases(fn, ...)) is not eliminated from a production bundle just because@adobe/data-testing'spackage.jsonsetssideEffects: false— that flag only lets a bundler drop an unused import of the package.Conformance.cases(fn, ...)/Conformance.derivations(fn, ...)is an ordinary, unannotated function call happening in the consuming transform file, so Rollup/esbuild conservatively keeps it whenever the module is reachable (i.e. wheneverfnitself is genuinely used), even though thecasesexport it initializes is never read.data-lit-todo): wiring a transition into the actual app entry point and calling only the function (nevercases) shipped the full case-fixture data and the builder's inlined logic into the bundle. Adding/*@__PURE__*/immediately before the call eliminated it completely, confirmed by rebuild.Conformance.cases(...)/Conformance.derivations(...)call sites across the reference apps (data-lit-todo,data-lit-tictactoe,data-gpu-hopper,data-lit-space-rock-game,data-react-pixie), corrects the misleadingsideEffects: falsecomment inpackages/data-testing/src/index.ts, and updates thedata-aiguidance (state.md) to require the annotation on every future call, with the mechanism explained so it isn't dropped by accident.pnpm -w run bumpversion bump included per workspace convention.Test plan
pnpm run lint— passespnpm run typecheck— passes across all 18 workspace packagespnpm --filter <touched-app> run test— all pass (data-lit-todo 106/106, data-lit-tictactoe 99/99, data-lit-space-rock-game 135/135, data-gpu-hopper 90/90, data-react-pixie 42/42, data-testing 18/18)🤖 Generated with Claude Code