[audit] framer-motion/animation: remove dead code#3733
Conversation
Greptile SummaryThis PR makes two targeted changes to
Confidence Score: 5/5Safe to merge — all three changes are narrow and well-reasoned with no risk of regressions. The No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["startOptimizedAppearAnimation()"] --> B{readyAnimation exists?}
B -->|No| C["Create readyAnimation (dummy 10s WAAPI)"]
C --> D[Register window.Motion handlers]
D --> E{readyAnimation.ready?}
B -->|Yes| E
E -->|Promise| F["readyAnimation.ready.then(startAnimation)"]
E -->|No promise| G["startAnimation() sync"]
F --> H["startAnimation() microtask"]
G --> I{startFrameTime === undefined?}
H --> I
I -->|Yes| J["startFrameTime = time.now()"]
I -->|No| K[Reuse existing startFrameTime]
J --> L["appearAnimation.startTime = startFrameTime"]
K --> L
L --> M[Store in appearAnimationStore]
Reviews (1): Last reviewed commit: "[audit] framer-motion/animation: time.no..." | Re-trigger Greptile |
Filesize / maintainability: - Remove utils/is-keyframes-target.ts — unused duplicate of motion-dom's own is-keyframes-target (the only consumed copy). No importer repo-wide. - Remove utils/variant-resolvers.ts — resolveVariantLabels / asDependencyList have zero references repo-wide. Both already tree-shaken out of every bundle, so this is a source cleanup with ~0 gzipped delta, not a filesize win. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
18caece to
948a01b
Compare
What this directory does
packages/framer-motion/src/animationis the React-side animation entry layer: theanimate()/useAnimatefactories, sequence resolution (sequence/), the WAAPI mini animators (animators/waapi/), the legacy animation controls hooks, and the optimized-appear handoff used for SSR/streamed appear animations. It is setup/teardown code — none of it runs inside a per-frame render or update tick (per-frame work lives in motion-dom's JSAnimation/frameloop/projection). Hot-path callers were confirmed by grep:createAnimationsFromSequenceruns once at animation start,animateElementsonce peranimate()call, optimized-appear once per value at handoff.Both lenses (performance and filesize) were applied.
Performance
No per-frame hot path exists in this directory, so there are no frame-loop allocation/closure findings (cold-path micro-optimisation is intentionally not listed). No changes.
(An earlier revision swapped
performance.now()totime.now()inoptimized-appear/start.ts; this was reverted at the maintainer's request and is no longer part of this PR.)Filesize
Baseline vs after, minified production bundles,
gzip -9— all unchanged:Dead code removal — source cleanup, ~0 bundle impact (stated honestly):
utils/is-keyframes-target.ts—isKeyframesTargethere is an unused duplicate; the only consumedisKeyframesTargetis motion-dom's own (motion-dom/src/render/utils/is-keyframes-target.ts). No importer anywhere in the repo.utils/variant-resolvers.ts—resolveVariantLabels/asDependencyListhave zero references repo-wide (packages + dev).Because neither file was imported anywhere, both were already tree-shaken out of every bundle — deleting them does not shrink the gzipped output (hence the 0 deltas). Framed as maintainability cleanup, not a filesize win.
animation/types.ts(ResolveKeyframes) was flagged as unused internally but is re-exported viaexport type * from "./animation/types"in the public index — it is public type API, so left untouched (no public API changes).Testing
yarn build— all 8 tasks pass.act()warning inuse-animated-stateis unrelated).🤖 Generated with Claude Code