-
Notifications
You must be signed in to change notification settings - Fork 109
feat: delay the createSnapshot operation #1899
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: a0ca8ef The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
📝 WalkthroughWalkthroughAdds a public snapshotCreatorMap and moves snapshot instantiation from eager inline calls to lazy, registry-driven creators; runtime Snapshot/BackgroundSnapshot consult the map for on-demand creation; transform outputs register creators into that map; tests and patch formats updated to the new shape. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related issues
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
❌ 1 Tests Failed:
View the top 2 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
packages/react/transform/crates/swc_plugin_snapshot/lib.rs (1)
1435-1442: Outdated comment about CSS ID skipComment mentions “skip when cssId === undefined && entryName === undefined”, but
entryNameis always emitted asglobDynamicComponentEntryhere. Please update the comment to avoid confusion.packages/react/runtime/src/snapshot.ts (1)
203-247: Normalizeslotto an empty array to tolerate older/new emitters.Transformer currently emits
nullin some tests. Runtime assumes array semantics (length, indexing). Normalize here defensively.export function createSnapshot( uniqID: string, create: Snapshot['create'] | null, update: Snapshot['update'] | null, slot: Snapshot['slot'], cssId: number | undefined, entryName: string | undefined, refAndSpreadIndexes: number[] | null, entryUniqID: string | undefined, ): string { entryUniqID ??= calcEntryUniqID(uniqID, entryName); + // Defensive: some legacy emitters may pass `null` + // Ensure downstream code can safely call `.length`/index. + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + slot = (slot ?? []) as Snapshot['slot']; if ( __DEV__ && __JS__ @@ const s: Snapshot = { create, update, slot, cssId, entryName, refAndSpreadIndexes }; snapshotManager.values.set(entryUniqID, s); @@ return entryUniqID; }
🧹 Nitpick comments (9)
.changeset/full-brooms-care.md (1)
2-5: Consider MINOR bump and add API notes.You’re adding a new public API (snapshotCreatorMap via internal) and extending createSnapshot’s signature (optional). That’s more than a patch. Suggest minor and expand the notes for consumers.
Apply:
--- -"@lynx-js/react": patch +"@lynx-js/react": minor --- -Delay the `createSnapshot` operation to speed up IFR +Delay the `createSnapshot` operation to speed up IFR. + +- New: `snapshotCreatorMap` (exposed via `@lynx-js/react/internal`) for lazy per-snapshot factory registration. +- Update: `createSnapshot` accepts an optional `entryUniqID` (backward‑compatible). +- Behavior: Snapshots are created on first use; no migration expected for app code. Transform plugin emits registrations automatically.packages/react/transform/crates/swc_plugin_snapshot/lib.rs (2)
1464-1466: I need to verify there are no reads of this field. Let me search for usage patterns:Let me search the codebase more specifically for any reads or usages of this field:
Let me search more precisely in the codebase for any reads of this field:
Based on the initial ripgrep output showing only 3 matches for
current_snapshot_id(at lines 1018, 1050, and 1464), which are all writes (declaration, initialization, and assignment), and no other references appearing in the context output, the review comment's assertion is correct. The field is declared, initialized, and assigned at line 1464, but there are no reads of this field anywhere in the codebase.The review comment is valid—
self.current_snapshot_id = Some(snapshot_id.clone());can be safely removed as an optional refactoring since the field is never read after being assigned. Removing this assignment would eliminate unnecessary state management and a redundant clone operation.Remove unused
current_snapshot_idstateThe assignment
self.current_snapshot_id = Some(snapshot_id.clone());at line 1464 sets a field that is never read. Remove this assignment to simplify the code and eliminate the unnecessary clone.
1447-1458: Add comment tying the two mechanisms together to prevent future drift.The review correctly identifies that entry key logic is duplicated across the transform and runtime. The transform precomputes
entry_snapshot_uid(combiningglobDynamicComponentEntryandsnapshot_uidfor dynamic components), then passes bothglobDynamicComponentEntryasentryNameand the precomputed key asentryUniqIDto the runtime'screateSnapshot(). The runtime then hascalcEntryUniqID()logic that could recompute this fromentryName.Since both
entryNameand the composed key are being passed, add a clarifying comment at lines 1447-1450 documenting the relationship tocalcEntryUniqID()to prevent these two implementations from drifting apart during future maintenance.packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static.js (1)
3-3: Guard against duplicate registrations (HMR/re-evaluation).Optional: avoid clobbering an existing entry to be safer under HMR.
-ReactLynx.snapshotCreatorMap[__snapshot_da39a_test_1] = ()=>ReactLynx.createSnapshot(/*…*/, __snapshot_da39a_test_1); +ReactLynx.snapshotCreatorMap[__snapshot_da39a_test_1] ||= () => ReactLynx.createSnapshot(/*…*/, __snapshot_da39a_test_1);packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component.js (1)
4-66: Optional: avoid overwriting existing entries (HMR-safe).Same recommendation as elsewhere—use ||= to prevent re-registering factories during HMR/module re-evals.
-ReactLynx.snapshotCreatorMap[__snapshot_da39a_test_1] = ()=>ReactLynx.createSnapshot("__snapshot_da39a_test_1", /*…*/, __snapshot_da39a_test_1); +ReactLynx.snapshotCreatorMap[__snapshot_da39a_test_1] ||= () => ReactLynx.createSnapshot("__snapshot_da39a_test_1", /*…*/, __snapshot_da39a_test_1);packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_dynamic_inline_style.js (1)
2-10: Creators are correct; tiny micro-optimizations optional in style updaters.
- All creators pass the key as the last parameter; good.
- Optional: in the generated updater functions, early-return when
!ctx.__elementsto avoid nesting.Also applies to: 12-25, 29-42, 51-63
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (1)
2-38: All snapshot creators are correctly wired with keys as final arguments; optional refactoring suggested.Verification confirms:
- All 7 snapshot creator registrations (
__snapshot_da39a_test_1through__snapshot_da39a_test_7) pass their snapshot keys as the final argument tocreateSnapshot().- Optional refactoring opportunity: hoisting the repeated
require('@lynx-js/react/internal')calls into a single binding would reduce generated code repetition and improve maintainability.packages/react/runtime/src/snapshot.ts (2)
138-139: Harden snapshotCreatorMap against prototype collisions.Use a dictionary with null-prototype to avoid edge-key collisions while keeping bracket assignment compatible with emitted code.
-export const snapshotCreatorMap: Record<string, () => string> = {}; +export const snapshotCreatorMap: Record<string, () => string> = + Object.create(null) as Record<string, () => string>;
202-211: API surface changed — document and add a changeset.
createSnapshotaddsentryUniqID, andcalcEntryUniqIDis new. Please update docs and include a changeset marking the signature change (even if internal).I can draft the changeset and a short doc blurb for
snapshotCreatorMap,calcEntryUniqID, and the newcreateSnapshotparam. Want me to open a follow-up?
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (44)
.changeset/full-brooms-care.md(1 hunks)packages/react/runtime/src/backgroundSnapshot.ts(1 hunks)packages/react/runtime/src/internal.ts(1 hunks)packages/react/runtime/src/lifecycle/patch/snapshotPatchApply.ts(3 hunks)packages/react/runtime/src/snapshot.ts(5 hunks)packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js(2 hunks)packages/react/transform/crates/swc_plugin_snapshot/lib.rs(2 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling_jsx.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling_jsx_dev.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_event.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_expr_container.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_expr_container_with_static_sibling.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static_snapshot_extract.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static_snapshot_extract_it.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list_toplevel.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list_with_fragment.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_ref.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_spread.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_timing_flag.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_comments.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_map_jsx.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_new_line.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_self_close.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/gesture.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/inline_style_literal.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/inline_style_literal_unknown_property.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/mode_development_spread.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_component.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_element.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_element_dev.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_escape_newline_character.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component_without_css_id.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_without_css_id.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_inject_implicit_flatten.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_dynamic_inline_style.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_inline_style.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_wrap_dynamic_key.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/worklet.js(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
.changeset/*.md
📄 CodeRabbit inference engine (AGENTS.md)
For contributions, generate and commit a Changeset describing your changes
Files:
.changeset/full-brooms-care.md
🧠 Learnings (6)
📚 Learning: 2025-09-18T04:43:54.426Z
Learnt from: gaoachao
PR: lynx-family/lynx-stack#1771
File: packages/react/transform/tests/__swc_snapshots__/src/swc_plugin_snapshot/mod.rs/basic_component_with_static_sibling.js:2-2
Timestamp: 2025-09-18T04:43:54.426Z
Learning: In packages/react/transform/src/swc_plugin_compat/mod.rs, the `add_pure_comment` function at lines 478-482 is specifically for `wrapWithLynxComponent` calls, not `createSnapshot` calls. The PURE comment injection for `createSnapshot` is handled separately in swc_plugin_snapshot/mod.rs. These are two distinct code paths that should be treated differently.
Applied to files:
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_spread.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_escape_newline_character.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_comments.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/worklet.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_without_css_id.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_element.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_dynamic_inline_style.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_component.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component_without_css_id.jspackages/react/transform/crates/swc_plugin_snapshot/lib.rspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_new_line.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/gesture.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_map_jsx.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/inline_style_literal_unknown_property.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/mode_development_spread.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_inline_style.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_inject_implicit_flatten.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_event.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling_jsx_dev.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list_toplevel.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_expr_container.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/inline_style_literal.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_timing_flag.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_self_close.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_expr_container_with_static_sibling.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static_snapshot_extract_it.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static_snapshot_extract.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_element_dev.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_ref.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling_jsx.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_wrap_dynamic_key.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list_with_fragment.js
📚 Learning: 2025-09-18T04:43:54.426Z
Learnt from: gaoachao
PR: lynx-family/lynx-stack#1771
File: packages/react/transform/tests/__swc_snapshots__/src/swc_plugin_snapshot/mod.rs/basic_component_with_static_sibling.js:2-2
Timestamp: 2025-09-18T04:43:54.426Z
Learning: In the lynx-family/lynx-stack repository, the `add_pure_comment` function in packages/react/transform/src/swc_plugin_compat/mod.rs (around lines 478-482) is specifically for `wrapWithLynxComponent` calls, not `createSnapshot` calls. The PURE comment injection for `createSnapshot` is handled separately in swc_plugin_snapshot/mod.rs.
Applied to files:
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_spread.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_escape_newline_character.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_comments.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/worklet.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_without_css_id.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_element.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_dynamic_inline_style.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_component.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component_without_css_id.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_new_line.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/gesture.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_map_jsx.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/inline_style_literal_unknown_property.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/mode_development_spread.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_inline_style.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_inject_implicit_flatten.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_event.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling_jsx_dev.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list_toplevel.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_expr_container.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/inline_style_literal.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_timing_flag.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_self_close.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_expr_container_with_static_sibling.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static_snapshot_extract_it.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static_snapshot_extract.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_element_dev.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_ref.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling_jsx.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_wrap_dynamic_key.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list_with_fragment.js
📚 Learning: 2025-08-12T16:09:32.413Z
Learnt from: colinaaa
PR: lynx-family/lynx-stack#1497
File: packages/react/transform/tests/__swc_snapshots__/src/swc_plugin_snapshot/mod.rs/basic_full_static.js:9-10
Timestamp: 2025-08-12T16:09:32.413Z
Learning: In the Lynx stack, functions prefixed with `__` that are called in transformed code may be injected globally by the Lynx Engine at runtime rather than exported from the React runtime package. For example, `__CreateFrame` is injected globally by the Lynx Engine, not exported from lynx-js/react.
Applied to files:
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_spread.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_comments.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/worklet.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_without_css_id.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_element.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_dynamic_inline_style.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_component.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_new_line.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/gesture.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_map_jsx.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/inline_style_literal_unknown_property.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/mode_development_spread.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_inline_style.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_event.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling_jsx_dev.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_expr_container.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/inline_style_literal.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_timing_flag.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_self_close.jspackages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_expr_container_with_static_sibling.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static_snapshot_extract_it.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static_snapshot_extract.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_element_dev.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_ref.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling_jsx.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_wrap_dynamic_key.js
📚 Learning: 2025-09-23T08:54:39.966Z
Learnt from: upupming
PR: lynx-family/lynx-stack#1670
File: packages/webpack/css-extract-webpack-plugin/test/hotCases/hot/hot-update-json/dual-thread/__snapshot__/index.css:6-8
Timestamp: 2025-09-23T08:54:39.966Z
Learning: In the lynx-stack CSS extract webpack plugin tests, many test fixture CSS files intentionally use invalid CSS syntax like `color: 'red';` with quoted values. The snapshots correctly reflect this invalid CSS from the source fixtures. To fix CSS validation issues, the source fixture files should be updated first, then snapshots regenerated, rather than manually editing snapshots.
Applied to files:
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_without_css_id.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_dynamic_inline_style.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id.js
📚 Learning: 2025-08-21T07:21:51.621Z
Learnt from: upupming
PR: lynx-family/lynx-stack#1562
File: packages/react/transform/src/swc_plugin_snapshot/jsx_helpers.rs:261-283
Timestamp: 2025-08-21T07:21:51.621Z
Learning: In packages/react/transform/src/swc_plugin_snapshot/jsx_helpers.rs, the team prefers to keep the original unreachable! logic for JSXSpreadChild in jsx_is_children_full_dynamic function rather than implementing defensive error handling.
Applied to files:
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_map_jsx.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling_jsx.js
📚 Learning: 2025-08-27T12:42:01.095Z
Learnt from: upupming
PR: lynx-family/lynx-stack#1616
File: packages/webpack/cache-events-webpack-plugin/test/cases/not-cache-events/lazy-bundle/index.js:3-3
Timestamp: 2025-08-27T12:42:01.095Z
Learning: In webpack, properties like __webpack_require__.lynx_ce are injected during compilation/build time when webpack processes modules and generates bundles, not at runtime when dynamic imports execute. Tests for such properties don't need to wait for dynamic imports to complete.
Applied to files:
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_element_dev.js
🧬 Code graph analysis (40)
packages/react/runtime/src/backgroundSnapshot.ts (1)
packages/react/runtime/src/snapshot.ts (2)
snapshotManager(58-123)snapshotCreatorMap(138-138)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_spread.js (2)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (1)
__snapshot_da39a_test_1(2-2)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (1)
__snapshot_da39a_test_1(2-2)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_escape_newline_character.js (2)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (15)
__snapshot_da39a_test_1(2-2)pageId(4-4)pageId(17-17)pageId(25-25)pageId(33-33)pageId(51-51)pageId(64-64)pageId(78-78)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_comments.js (2)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static.js (5)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)el1(6-6)el2(8-8)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/worklet.js (2)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (15)
__snapshot_da39a_test_1(2-2)pageId(4-4)pageId(17-17)pageId(25-25)pageId(33-33)pageId(51-51)pageId(64-64)pageId(78-78)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_without_css_id.js (2)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (15)
__snapshot_da39a_test_1(2-2)pageId(4-4)pageId(17-17)pageId(25-25)pageId(33-33)pageId(51-51)pageId(64-64)pageId(78-78)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)
packages/react/runtime/src/lifecycle/patch/snapshotPatchApply.ts (1)
packages/react/runtime/src/snapshot.ts (2)
calcEntryUniqID(198-200)snapshotManager(58-123)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_element.js (2)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (15)
__snapshot_da39a_test_1(2-2)pageId(4-4)pageId(17-17)pageId(25-25)pageId(33-33)pageId(51-51)pageId(64-64)pageId(78-78)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_dynamic_inline_style.js (3)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (16)
__snapshot_da39a_test_1(2-2)pageId(4-4)pageId(17-17)pageId(25-25)pageId(33-33)pageId(51-51)pageId(64-64)pageId(78-78)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)__snapshot_da39a_test_2(15-15)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component.js (1)
__snapshot_da39a_test_2(14-14)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_component.js (2)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (15)
__snapshot_da39a_test_1(2-2)pageId(4-4)pageId(17-17)pageId(25-25)pageId(33-33)pageId(51-51)pageId(64-64)pageId(78-78)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component_without_css_id.js (1)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component.js (3)
__snapshot_da39a_test_2(14-14)__snapshot_da39a_test_3(31-31)__snapshot_da39a_test_4(52-52)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_new_line.js (3)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling.js (5)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)el1(6-6)el2(8-8)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static.js (5)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)el1(6-6)el2(8-8)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/gesture.js (2)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_event.js (5)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)el1(6-6)el2(8-8)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/inline_style_literal_unknown_property.js (2)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (15)
__snapshot_da39a_test_1(2-2)pageId(4-4)pageId(17-17)pageId(25-25)pageId(33-33)pageId(51-51)pageId(64-64)pageId(78-78)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/mode_development_spread.js (3)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (1)
__snapshot_da39a_test_1(2-2)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (1)
__snapshot_da39a_test_1(2-2)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_spread.js (1)
__snapshot_da39a_test_1(3-3)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_inline_style.js (2)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (16)
__snapshot_da39a_test_1(2-2)pageId(4-4)pageId(17-17)pageId(25-25)pageId(33-33)pageId(51-51)pageId(64-64)pageId(78-78)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)__snapshot_da39a_test_2(15-15)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_inject_implicit_flatten.js (3)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (2)
__snapshot_da39a_test_2(15-15)__snapshot_da39a_test_1(2-2)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list.js (2)
__snapshot_da39a_test_2(12-12)__snapshot_da39a_test_1(33-33)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component.js (1)
__snapshot_da39a_test_2(14-14)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static.js (4)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (15)
__snapshot_da39a_test_1(2-2)pageId(4-4)pageId(17-17)pageId(25-25)pageId(33-33)pageId(51-51)pageId(64-64)pageId(78-78)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling.js (5)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)el1(6-6)el2(8-8)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static_snapshot_extract.js (5)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)el1(6-6)el2(8-8)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_event.js (2)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (1)
__snapshot_da39a_test_1(2-2)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (1)
__snapshot_da39a_test_1(2-2)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling_jsx_dev.js (2)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling.js (6)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)el1(6-6)el2(8-8)el3(10-10)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list_toplevel.js (2)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (3)
__snapshot_da39a_test_2(15-15)__snapshot_da39a_test_3(23-23)__snapshot_da39a_test_1(2-2)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list.js (3)
__snapshot_da39a_test_2(12-12)__snapshot_da39a_test_3(2-2)__snapshot_da39a_test_1(33-33)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_expr_container.js (2)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (15)
__snapshot_da39a_test_1(2-2)pageId(4-4)pageId(17-17)pageId(25-25)pageId(33-33)pageId(51-51)pageId(64-64)pageId(78-78)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component.js (2)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (1)
__snapshot_da39a_test_1(2-2)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component_without_css_id.js (3)
__snapshot_da39a_test_2(12-12)__snapshot_da39a_test_3(29-29)__snapshot_da39a_test_4(50-50)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (2)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (15)
__snapshot_da39a_test_1(2-2)pageId(4-4)pageId(17-17)pageId(25-25)pageId(33-33)pageId(51-51)pageId(64-64)pageId(78-78)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/inline_style_literal.js (1)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (1)
__snapshot_da39a_test_1(2-2)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_timing_flag.js (3)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (15)
__snapshot_da39a_test_1(2-2)pageId(4-4)pageId(17-17)pageId(25-25)pageId(33-33)pageId(51-51)pageId(64-64)pageId(78-78)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_event.js (4)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)el1(6-6)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling.js (3)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (15)
__snapshot_da39a_test_1(2-2)pageId(4-4)pageId(17-17)pageId(25-25)pageId(33-33)pageId(51-51)pageId(64-64)pageId(78-78)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling_jsx.js (6)
__snapshot_da39a_test_1(3-3)pageId(5-5)el(6-6)el1(7-7)el2(9-9)el3(11-11)
packages/react/runtime/src/snapshot.ts (2)
packages/react/runtime/src/internal.ts (2)
snapshotCreatorMap(21-21)snapshotManager(21-21)packages/react/runtime/src/lifecycle/patch/snapshotPatch.ts (1)
__globalSnapshotPatch(53-53)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list.js (4)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (10)
__snapshot_da39a_test_3(23-23)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)__snapshot_da39a_test_2(15-15)__snapshot_da39a_test_1(2-2)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list_toplevel.js (3)
__snapshot_da39a_test_3(13-13)__snapshot_da39a_test_2(2-2)__snapshot_da39a_test_1(24-24)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component.js (2)
__snapshot_da39a_test_3(31-31)__snapshot_da39a_test_2(14-14)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (2)
el(5-5)__snapshot_da39a_test_1(2-2)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_self_close.js (1)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (2)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_event.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id.js (3)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (16)
__snapshot_da39a_test_1(2-2)pageId(4-4)pageId(17-17)pageId(25-25)pageId(33-33)pageId(51-51)pageId(64-64)pageId(78-78)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)__snapshot_da39a_test_2(15-15)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component.js (1)
__snapshot_da39a_test_2(14-14)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_expr_container_with_static_sibling.js (4)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (15)
__snapshot_da39a_test_1(2-2)pageId(4-4)pageId(17-17)pageId(25-25)pageId(33-33)pageId(51-51)pageId(64-64)pageId(78-78)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_expr_container.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static_snapshot_extract_it.js (2)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static.js (5)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)el1(6-6)el2(8-8)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static_snapshot_extract.js (2)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static.js (5)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)el1(6-6)el2(8-8)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_element_dev.js (1)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (15)
__snapshot_da39a_test_1(2-2)pageId(4-4)pageId(17-17)pageId(25-25)pageId(33-33)pageId(51-51)pageId(64-64)pageId(78-78)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_ref.js (3)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (1)
__snapshot_da39a_test_1(2-2)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (1)
__snapshot_da39a_test_1(2-2)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_event.js (1)
__snapshot_da39a_test_1(2-2)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling_jsx.js (4)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (1)
__snapshot_da39a_test_1(2-2)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (1)
__snapshot_da39a_test_1(2-2)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling.js (1)
__snapshot_da39a_test_1(2-2)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling_jsx_dev.js (1)
__snapshot_da39a_test_1(3-3)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_wrap_dynamic_key.js (3)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (3)
__snapshot_da39a_test_2(15-15)__snapshot_da39a_test_3(23-23)__snapshot_da39a_test_1(2-2)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list.js (3)
__snapshot_da39a_test_2(12-12)__snapshot_da39a_test_3(2-2)__snapshot_da39a_test_1(33-33)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component.js (2)
__snapshot_da39a_test_2(14-14)__snapshot_da39a_test_3(31-31)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list_with_fragment.js (1)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (1)
__snapshot_da39a_test_3(23-23)
🪛 GitHub Actions: Test
packages/react/runtime/src/backgroundSnapshot.ts
[error] 28-37: dprint: Found 2 not formatted files.
packages/react/runtime/src/internal.ts
[error] 18-29: dprint: Found 2 not formatted files.
...wc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling_jsx.js
Outdated
Show resolved
Hide resolved
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_ref.js
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pls fix the "4 failing checks"
2ec11ac to
7952387
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (2)
packages/react/runtime/src/snapshot.ts (1)
286-289: Guard missing creators to avoid TypeError; throw clear error.Calling
snapshotCreatorMap[type]!()will crash when unregistered. Guard and fail gracefully.Apply this diff:
constructor(public type: string, id?: number) { - if (!snapshotManager.values.has(type)) { - snapshotCreatorMap[type]!(); - } - this.__snapshot_def = snapshotManager.values.get(type)!; - // Suspense uses 'div' - if (!this.__snapshot_def && type !== 'div') { - throw new Error('Snapshot not found: ' + type); - } + if (!snapshotManager.values.has(type)) { + const creator = snapshotCreatorMap[type]; + if (creator) { + creator(); + } + } + this.__snapshot_def = snapshotManager.values.get(type)!; + // Suspense uses 'div' + if (!this.__snapshot_def && type !== 'div') { + throw new Error(`Snapshot not found or not registered: ${type}`); + }packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_ref.js (1)
27-34: Slot must not be null (runtime expects an array).Runtime uses slot.length and indexing; null will crash. Emit [] instead.
Apply:
- ], null, undefined, globDynamicComponentEntry, [ + ], [], undefined, globDynamicComponentEntry, [Based on learnings.
🧹 Nitpick comments (9)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list.js (1)
33-55: Verify slot indices remain stable if structure changes.DynamicPartSlot targets indices 1 and 2, consistent with return [el, el1, el2]. If wrappers are reordered later, remember to update these indices.
Consider named constants for slot positions to avoid off-by-one drift in future refactors.
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id.js (1)
14-27: Small resilience tweak (optional).If multiple values are expected later, consider early-return when ctx.__values is missing/empty to avoid silent no-ops.
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static_snapshot_extract_it.js (1)
2-15: Avoid cross-test leakage from global registry.Since ReactLynx.snapshotCreatorMap is global, ensure tests reset it between cases to prevent stale entries from previous specs.
You can add a beforeEach/afterEach in the test harness to clear only the keys created in a spec.
packages/react/runtime/src/snapshot.ts (1)
138-139: Harden the registry against prototype pollution.Use a null‑prototype object to avoid
__proto__collisions and accidental inherited props.Apply this diff:
-export const snapshotCreatorMap: Record<string, () => string> = {}; +export const snapshotCreatorMap = Object.create(null) as Record<string, () => string>;packages/react/transform/crates/swc_plugin_snapshot/lib.rs (1)
1416-1443: Registration logic looks good; small robustness nit onundefined.Use
void 0instead of anundefinedidentifier to avoid rare shadowing.Apply:
- css_id: Expr = match &self.css_id_value { - Some(css_id_expr) => css_id_expr.clone(), - // We use `undefined` here since runtime will skip `__SetCSSId` when `cssId === undefined && entryName === undefined` - None => Expr::Ident("undefined".into()), - }, + css_id: Expr = match &self.css_id_value { + Some(css_id_expr) => css_id_expr.clone(), + // Use `void 0` to avoid potential shadowing of `undefined` + None => quote!("void 0" as Expr), + },packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/worklet.js (1)
25-34: Optional: avoid mixed ESM+CJS in generated snapshots.If snapshots are ever executed (not just string-compared), prefer a consistent module style (all ESM or all CJS) to reduce runtime friction. Here, consider importing the internal API via ESM for consistency with the
_jsximport.packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (1)
3-14: Cut repeated require()s; ensure factories run at most once.
- Cache require('@lynx-js/react/internal') locally to avoid repeated lookups.
- Confirm snapshotCreatorMap entries are replaced/cached after first invocation to prevent duplicate createSnapshot calls if accessed multiple times.
Example refactor:
- require('@lynx-js/react/internal').snapshotCreatorMap[__snapshot_da39a_test_1] = ()=>require('@lynx-js/react/internal').createSnapshot( + const ReactInternal = require('@lynx-js/react/internal'); + ReactInternal.snapshotCreatorMap[__snapshot_da39a_test_1] = () => ReactInternal.createSnapshot(Optional: if not already in runtime, wrap factories with a once() so the first call memoizes the created snapshot.
Also applies to: 16-38, 50-61, 63-69, 77-88
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_element_dev.js (1)
3-9: Minor: cache internal module locally for readability.Reduce repetition and improve readability by caching require('@lynx-js/react/internal') to a local const before use.
- require('@lynx-js/react/internal').snapshotCreatorMap[__snapshot_da39a_test_1] = ()=>require('@lynx-js/react/internal').createSnapshot( + const ReactInternal = require('@lynx-js/react/internal'); + ReactInternal.snapshotCreatorMap[__snapshot_da39a_test_1] = () => ReactInternal.createSnapshot(packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (1)
3-9: Ensure public export mirrors internal registry instance.This registers via ReactLynx.snapshotCreatorMap; other files use internal.snapshotCreatorMap. Please confirm both resolve to the same underlying object to avoid split registries.
If not identical, standardize registration to one module.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (44)
.changeset/full-brooms-care.md(1 hunks)packages/react/runtime/src/backgroundSnapshot.ts(1 hunks)packages/react/runtime/src/internal.ts(1 hunks)packages/react/runtime/src/lifecycle/patch/snapshotPatchApply.ts(2 hunks)packages/react/runtime/src/snapshot.ts(3 hunks)packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js(2 hunks)packages/react/transform/crates/swc_plugin_snapshot/lib.rs(3 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling_jsx.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling_jsx_dev.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_event.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_expr_container.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_expr_container_with_static_sibling.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static_snapshot_extract.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static_snapshot_extract_it.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list_toplevel.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list_with_fragment.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_ref.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_spread.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_timing_flag.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_comments.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_map_jsx.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_new_line.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_self_close.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/gesture.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/inline_style_literal.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/inline_style_literal_unknown_property.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/mode_development_spread.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_component.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_element.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_element_dev.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_escape_newline_character.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component_without_css_id.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_without_css_id.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_inject_implicit_flatten.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_dynamic_inline_style.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_inline_style.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_wrap_dynamic_key.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/worklet.js(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (14)
- packages/react/runtime/src/backgroundSnapshot.ts
- packages/react/transform/crates/swc_plugin_snapshot/tests/swc_snapshots/lib.rs/basic_component_with_static_sibling.js
- packages/react/transform/crates/swc_plugin_snapshot/tests/swc_snapshots/lib.rs/should_extract_css_id_without_css_id.js
- packages/react/runtime/src/lifecycle/patch/snapshotPatchApply.ts
- packages/react/transform/crates/swc_plugin_snapshot/tests/swc_snapshots/lib.rs/should_escape_newline_character.js
- packages/react/transform/crates/swc_plugin_snapshot/tests/swc_snapshots/lib.rs/basic_full_static_snapshot_extract.js
- packages/react/transform/crates/swc_plugin_snapshot/tests/swc_snapshots/lib.rs/basic_full_static.js
- packages/react/transform/crates/swc_plugin_snapshot/tests/swc_snapshots/lib.rs/basic_component_with_static_sibling_jsx.js
- packages/react/transform/crates/swc_plugin_snapshot/tests/swc_snapshots/lib.rs/full_static_children_map_jsx.js
- packages/react/transform/crates/swc_plugin_snapshot/tests/swc_snapshots/lib.rs/basic_event.js
- packages/react/transform/crates/swc_plugin_snapshot/tests/swc_snapshots/lib.rs/basic_component_with_static_sibling_jsx_dev.js
- packages/react/transform/crates/swc_plugin_snapshot/tests/swc_snapshots/lib.rs/full_static_children_comments.js
- packages/react/transform/crates/swc_plugin_snapshot/tests/swc_snapshots/lib.rs/inline_style_literal.js
- .changeset/full-brooms-care.md
🧰 Additional context used
🧠 Learnings (5)
📚 Learning: 2025-09-18T04:43:54.426Z
Learnt from: gaoachao
PR: lynx-family/lynx-stack#1771
File: packages/react/transform/tests/__swc_snapshots__/src/swc_plugin_snapshot/mod.rs/basic_component_with_static_sibling.js:2-2
Timestamp: 2025-09-18T04:43:54.426Z
Learning: In packages/react/transform/src/swc_plugin_compat/mod.rs, the `add_pure_comment` function at lines 478-482 is specifically for `wrapWithLynxComponent` calls, not `createSnapshot` calls. The PURE comment injection for `createSnapshot` is handled separately in swc_plugin_snapshot/mod.rs. These are two distinct code paths that should be treated differently.
Applied to files:
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_inject_implicit_flatten.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_wrap_dynamic_key.jspackages/react/transform/crates/swc_plugin_snapshot/lib.rspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component_without_css_id.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_self_close.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/inline_style_literal_unknown_property.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list_toplevel.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_new_line.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list_with_fragment.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/worklet.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_element.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static_snapshot_extract_it.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_expr_container.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_ref.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_expr_container_with_static_sibling.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_timing_flag.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/mode_development_spread.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_dynamic_inline_style.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/gesture.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_element_dev.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_inline_style.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_spread.jspackages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_component.js
📚 Learning: 2025-09-18T04:43:54.426Z
Learnt from: gaoachao
PR: lynx-family/lynx-stack#1771
File: packages/react/transform/tests/__swc_snapshots__/src/swc_plugin_snapshot/mod.rs/basic_component_with_static_sibling.js:2-2
Timestamp: 2025-09-18T04:43:54.426Z
Learning: In the lynx-family/lynx-stack repository, the `add_pure_comment` function in packages/react/transform/src/swc_plugin_compat/mod.rs (around lines 478-482) is specifically for `wrapWithLynxComponent` calls, not `createSnapshot` calls. The PURE comment injection for `createSnapshot` is handled separately in swc_plugin_snapshot/mod.rs.
Applied to files:
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_inject_implicit_flatten.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_wrap_dynamic_key.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component_without_css_id.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_self_close.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/inline_style_literal_unknown_property.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list_toplevel.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_new_line.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list_with_fragment.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/worklet.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_element.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static_snapshot_extract_it.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_expr_container.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_ref.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_expr_container_with_static_sibling.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_timing_flag.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/mode_development_spread.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_dynamic_inline_style.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/gesture.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_element_dev.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_inline_style.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_spread.jspackages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_component.js
📚 Learning: 2025-08-12T16:09:32.413Z
Learnt from: colinaaa
PR: lynx-family/lynx-stack#1497
File: packages/react/transform/tests/__swc_snapshots__/src/swc_plugin_snapshot/mod.rs/basic_full_static.js:9-10
Timestamp: 2025-08-12T16:09:32.413Z
Learning: In the Lynx stack, functions prefixed with `__` that are called in transformed code may be injected globally by the Lynx Engine at runtime rather than exported from the React runtime package. For example, `__CreateFrame` is injected globally by the Lynx Engine, not exported from lynx-js/react.
Applied to files:
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_self_close.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/inline_style_literal_unknown_property.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_new_line.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/worklet.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_element.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static_snapshot_extract_it.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_expr_container.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_ref.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_expr_container_with_static_sibling.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_timing_flag.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_dynamic_inline_style.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/gesture.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_element_dev.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_inline_style.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_spread.jspackages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_component.js
📚 Learning: 2025-09-23T08:54:39.966Z
Learnt from: upupming
PR: lynx-family/lynx-stack#1670
File: packages/webpack/css-extract-webpack-plugin/test/hotCases/hot/hot-update-json/dual-thread/__snapshot__/index.css:6-8
Timestamp: 2025-09-23T08:54:39.966Z
Learning: In the lynx-stack CSS extract webpack plugin tests, many test fixture CSS files intentionally use invalid CSS syntax like `color: 'red';` with quoted values. The snapshots correctly reflect this invalid CSS from the source fixtures. To fix CSS validation issues, the source fixture files should be updated first, then snapshots regenerated, rather than manually editing snapshots.
Applied to files:
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_dynamic_inline_style.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_inline_style.js
📚 Learning: 2025-08-27T12:42:01.095Z
Learnt from: upupming
PR: lynx-family/lynx-stack#1616
File: packages/webpack/cache-events-webpack-plugin/test/cases/not-cache-events/lazy-bundle/index.js:3-3
Timestamp: 2025-08-27T12:42:01.095Z
Learning: In webpack, properties like __webpack_require__.lynx_ce are injected during compilation/build time when webpack processes modules and generates bundles, not at runtime when dynamic imports execute. Tests for such properties don't need to wait for dynamic imports to complete.
Applied to files:
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_element_dev.js
🧬 Code graph analysis (26)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_inject_implicit_flatten.js (2)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (1)
__snapshot_da39a_test_2(15-15)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list.js (1)
__snapshot_da39a_test_2(12-12)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list.js (4)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (9)
__snapshot_da39a_test_3(23-23)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)__snapshot_da39a_test_1(2-2)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list_toplevel.js (2)
__snapshot_da39a_test_3(13-13)__snapshot_da39a_test_1(24-24)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list_with_fragment.js (2)
__snapshot_da39a_test_3(2-2)__snapshot_da39a_test_1(39-39)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (2)
el(5-5)__snapshot_da39a_test_1(2-2)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_wrap_dynamic_key.js (2)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component.js (2)
__snapshot_da39a_test_2(14-14)__snapshot_da39a_test_3(31-31)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (1)
__snapshot_da39a_test_1(2-2)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component_without_css_id.js (1)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component.js (3)
__snapshot_da39a_test_2(14-14)__snapshot_da39a_test_3(31-31)__snapshot_da39a_test_4(52-52)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_self_close.js (2)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (15)
__snapshot_da39a_test_1(2-2)pageId(4-4)pageId(17-17)pageId(25-25)pageId(33-33)pageId(51-51)pageId(64-64)pageId(78-78)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/inline_style_literal_unknown_property.js (2)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (15)
__snapshot_da39a_test_1(2-2)pageId(4-4)pageId(17-17)pageId(25-25)pageId(33-33)pageId(51-51)pageId(64-64)pageId(78-78)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list_toplevel.js (2)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (3)
__snapshot_da39a_test_2(15-15)__snapshot_da39a_test_3(23-23)__snapshot_da39a_test_1(2-2)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list.js (3)
__snapshot_da39a_test_2(12-12)__snapshot_da39a_test_3(2-2)__snapshot_da39a_test_1(33-33)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_new_line.js (2)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (15)
__snapshot_da39a_test_1(2-2)pageId(4-4)pageId(17-17)pageId(25-25)pageId(33-33)pageId(51-51)pageId(64-64)pageId(78-78)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list_with_fragment.js (2)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (4)
__snapshot_da39a_test_3(23-23)__snapshot_da39a_test_4(31-31)__snapshot_da39a_test_2(15-15)__snapshot_da39a_test_1(2-2)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list.js (4)
__snapshot_da39a_test_3(2-2)__snapshot_da39a_test_4(25-25)__snapshot_da39a_test_2(12-12)__snapshot_da39a_test_1(33-33)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/worklet.js (2)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (15)
__snapshot_da39a_test_1(2-2)pageId(4-4)pageId(17-17)pageId(25-25)pageId(33-33)pageId(51-51)pageId(64-64)pageId(78-78)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_event.js (4)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)el1(6-6)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static_snapshot_extract_it.js (2)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static.js (5)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)el1(6-6)el2(8-8)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_expr_container.js (1)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_ref.js (2)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (15)
__snapshot_da39a_test_1(2-2)pageId(4-4)pageId(17-17)pageId(25-25)pageId(33-33)pageId(51-51)pageId(64-64)pageId(78-78)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_event.js (5)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)el1(6-6)el2(8-8)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_expr_container_with_static_sibling.js (2)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (1)
__snapshot_da39a_test_1(2-2)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (1)
__snapshot_da39a_test_1(2-2)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id.js (2)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (4)
__snapshot_da39a_test_1(2-2)__snapshot_da39a_test_2(15-15)__snapshot_da39a_test_3(23-23)__snapshot_da39a_test_4(31-31)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component.js (3)
__snapshot_da39a_test_2(14-14)__snapshot_da39a_test_3(31-31)__snapshot_da39a_test_4(52-52)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_timing_flag.js (2)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (1)
__snapshot_da39a_test_1(2-2)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (1)
__snapshot_da39a_test_1(2-2)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/mode_development_spread.js (1)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_event.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_dynamic_inline_style.js (3)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (16)
__snapshot_da39a_test_1(2-2)pageId(4-4)pageId(17-17)pageId(25-25)pageId(33-33)pageId(51-51)pageId(64-64)pageId(78-78)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)__snapshot_da39a_test_2(15-15)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component.js (1)
__snapshot_da39a_test_2(14-14)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component.js (1)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component_without_css_id.js (3)
__snapshot_da39a_test_2(12-12)__snapshot_da39a_test_3(29-29)__snapshot_da39a_test_4(50-50)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/gesture.js (2)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_event.js (5)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)el1(6-6)el2(8-8)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_element_dev.js (2)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (15)
__snapshot_da39a_test_1(2-2)pageId(4-4)pageId(17-17)pageId(25-25)pageId(33-33)pageId(51-51)pageId(64-64)pageId(78-78)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_event.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_inline_style.js (3)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (15)
__snapshot_da39a_test_1(2-2)pageId(4-4)pageId(17-17)pageId(25-25)pageId(33-33)pageId(51-51)pageId(64-64)pageId(78-78)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static_snapshot_extract.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_spread.js (1)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (4)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (1)
__snapshot_da39a_test_1(2-2)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_event.js (1)
__snapshot_da39a_test_1(2-2)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list.js (2)
__snapshot_da39a_test_1(33-33)__snapshot_da39a_test_2(12-12)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component.js (1)
__snapshot_da39a_test_2(14-14)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (2)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling_jsx.js (3)
__snapshot_da39a_test_1(3-3)pageId(5-5)el(6-6)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_component.js (1)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: build / Build (Ubuntu)
- GitHub Check: build / Build (Windows)
🔇 Additional comments (34)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list_toplevel.js (3)
2-12: Registry wiring looks correct.Key → factory mapping matches the new lazy pattern; arguments to createSnapshot preserve the original semantics.
24-36: List children dynamic-part indexing matches JSX usage.Using ReactLynx.__DynamicPartListChildren at index 0 aligns with the array passed as children to <__snapshot_da39a_test_1>. Good.
2-36: Ensure snapshotCreatorMap is initialized before assignment.If ReactLynx.snapshotCreatorMap isn’t pre-initialized, property writes will throw. Please confirm runtime exports it as an object by module eval time.
Run to verify:
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list.js (2)
2-11: LGTM: factory registration with updates callback is consistent.The updates array preserves platform info via ReactLynx.updateListItemPlatformInfo; params order looks right.
12-24: Dynamic list children wiring is correct.Using ReactLynx.snapshotCreateList(snapshotInstance) with DynamicPartListChildren at index 0 matches downstream JSX.
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_inline_style.js (2)
2-10: LGTM: inline-style extraction preserved.createSnapshot factory mirrors original semantics; css string applies before return.
12-20: Consistent lazy registration across snapshots.Both keys are registered; usage remains <_snapshot…/>. No issues spotted.
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id.js (1)
4-12: CSS ID correctly propagated (100).All factories pass 100 to createSnapshot per @jsxCSSId. The style update functions are guarded and safe.
Also applies to: 14-27, 31-44, 53-66
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component.js (3)
4-12: Dynamic key composition matches runtime expectations.Using
${globDynamicComponentEntry}:<id>as the registry key and passing globDynamicComponentEntry into createSnapshot keeps type resolution consistent.
4-66: Note on PURE comments (FYI).PURE comment handling for createSnapshot is a separate path from wrapWithLynxComponent; this lazy pattern no longer needs PURE on the call site since execution is deferred. Based on learnings.
15-27: Guard against undefined globDynamicComponentEntry at load time.If this module loads before globDynamicComponentEntry is set, the keys may be malformed (e.g.,
":__snapshot…") and diverge from lookup keys.Add a quick check in the test harness, or ensure transform guarantees declaration ordering.
Also applies to: 32-44, 53-66
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/gesture.js (1)
2-17: LGTM: registration-based snapshot wiring is correct.Creator is registered before first render; matches lazy init via runtime. No issues.
packages/react/runtime/src/internal.ts (1)
17-17: Public export of snapshotCreatorMap: confirm API and docs.Export looks fine. Please update internal API docs and migration notes to mention the new registry and expected usage.
Would you like me to draft the doc blurb for CONTRIBUTING/README?
Also applies to: 21-28
packages/react/runtime/src/snapshot.ts (1)
212-213: LGTM: DEV patch gating on uniqID presence.This matches the “uniqID as content hash” model and avoids redundant DEV patches.
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_new_line.js (1)
2-18: LGTM: static snapshot now registered lazily.Registration and usage are consistent; no functional differences expected.
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_wrap_dynamic_key.js (1)
2-54: LGTM: registry wiring for dynamic-key variants is correct.Creators, slots, and render shape look consistent.
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_element.js (1)
3-10: LGTM: snapshot registered via factory; JSX now resolves through registry.Args preserved; lazy creation achieved.
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/inline_style_literal_unknown_property.js (1)
2-10: LGTM: registry-based wiring keeps inline-style behavior intact.No functional change beyond deferred creation.
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component_without_css_id.js (1)
2-11: LGTM: dynamic-component keys and default cssId(0) handled correctly.Keys incorporate
globDynamicComponentEntry; dynamic parts/slots unchanged; creation deferred.If helpful, confirm
globDynamicComponentEntryis guaranteed at module init in all runtimes using this transform.Also applies to: 12-26, 29-43, 50-64
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/mode_development_spread.js (1)
1-12: LGTM: dev-mode path uses internal runtime and preserves spread updater.Factory defers work; parameters unchanged.
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_inject_implicit_flatten.js (1)
2-10: LGTM: implicit-flatten case preserved with lazy snapshot registration.Dynamic parts, slots, and child wrappers retained.
Also applies to: 11-58
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_self_close.js (1)
2-18: LGTM: full-static self-closing snapshot registered correctly.Creation moved behind a factory; structure unchanged.
packages/react/transform/crates/swc_plugin_snapshot/lib.rs (2)
1463-1464: Emission order: defs before usage.Pushing
entry_snapshot_uid_defbeforesnapshot_defensures the key exists prior to JSX usage.
1445-1456: Dynamic key templating for components: OK.
${globDynamicComponentEntry}:${uid}composition matches emitted tests and keeps keys unique per entry.packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_spread.js (2)
3-20: Lazy registration pattern looks correct; confirm createSnapshot trailing args and globals.Registration precedes usage and keeps original builder logic intact. Please confirm:
- The final argument
[0]matches the current createSnapshot(...) signature/semantics for this case.globDynamicComponentEntryis defined in the test harness scope.
21-30: Verify updateSpread contract with new values payload shape.
valuesnow passes a single object with__spread: true, preserving key order"before", ...obj, "after". ConfirmReactLynx.updateSpread(...)decodes this shape and order correctly under the lazy snapshot flow.packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/worklet.js (1)
2-24: Worklet wiring and indices look right; double‑check internal API exposure.
updateWorkletEvent(..., 1, ...)andupdateWorkletRef(..., 3, ...)align with the returned node array. Please confirmsnapshotCreatorMapis intentionally exposed on@lynx-js/react/internalfor this path and kept in sync with the public export used elsewhere.packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_component.js (1)
2-9: LGTM; confirm children dynamic part mapping remains stable.Registration defers creation as intended. Please verify
ReactLynx.__DynamicPartChildren_0still maps the wrapper’s children correctly with the lazy registry.packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_expr_container.js (1)
2-9: Registration looks good; PURE handling is not required here.Deferring the call inside a factory makes prior PURE annotations for direct
createSnapshotunnecessary in this path, which aligns with how PURE handling is separated for snapshot creation.Based on learnings
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list_with_fragment.js (1)
2-9: Multi‑snapshot wiring reads correct; validate list/slot index contracts.
__DynamicPartListChildren, 0for the list snapshot and slot indices[1]/[2]for the wrapper match the builder return shapes.- Please confirm these indices and helpers remain unchanged with the lazy registry to avoid off‑by‑one regressions in list and slot updates.
Also applies to: 10-17, 18-30, 31-38, 39-61
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (1)
39-48: Verify test harness identifiers exist.This uses noop and globDynamicComponentEntry. Ensure both are in scope in the test harness to avoid ReferenceError at runtime.
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_expr_container_with_static_sibling.js (1)
3-23: Confirm registry identity: ReactLynx.snapshotCreatorMap vs internal.snapshotCreatorMap.Some files register via ReactLynx (public), others via require('@lynx-js/react/internal'). Mixing is safe only if both references point to the same object instance.
Run to check for mixed usage and ensure aliasing is intentional:
If they are different objects, standardize on internal or re-export the same instance from the public entry.
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_dynamic_inline_style.js (1)
3-10: Verify missing final snapshot ID parameter in all snapshot definitions.All four snapshot creator registrations appear to be missing the snapshot ID as the final parameter to
createSnapshot, based on the AI-generated summary. EachcreateSnapshotcall ends withnullinstead of the respective snapshot ID constant.Expected pattern for each:
- Line 10:
}, null, null, undefined, globDynamicComponentEntry, null, __snapshot_da39a_test_1);- Line 25:
}, null, undefined, globDynamicComponentEntry, null, __snapshot_da39a_test_2);- Line 42:
}, null, undefined, globDynamicComponentEntry, null, __snapshot_da39a_test_3);- Line 63:
}, null, undefined, globDynamicComponentEntry, null, __snapshot_da39a_test_4);Actual pattern (all end with
nullinstead):
- Lines 10, 25, 42, 63: All end with
globDynamicComponentEntry, null);This affects all snapshot definitions uniformly. Please verify whether the transform logic is correctly emitting the final snapshot ID parameter, or if the test expectations need updating.
Also applies to: 13-25, 30-42, 51-63
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_timing_flag.js (1)
3-21: The review comment is incorrect and should be dismissed.The
createSnapshotfunction signature accepts 7 parameters:uniqID,create,update,slot,cssId,entryName, andrefAndSpreadIndexes. The generated code inbasic_timing_flag.jscorrectly passes all 7 arguments and does not require a duplicate snapshot ID as a final parameter. This pattern is consistent across all snapshot test files in the codebase.Likely an incorrect or invalid review comment.
7952387 to
62038ad
Compare
CodSpeed Performance ReportMerging #1899 will degrade performances by 6.55%Comparing Summary
Benchmarks breakdown
Footnotes
|
React Example#6111 Bundle Size — 237.8KiB (+0.15%).a0ca8ef(current) vs 04f2c39 main#6104(baseline) Bundle metrics
Bundle size by type
Bundle analysis report Branch feat/lazy-snapshot-create Project dashboard Generated by RelativeCI Documentation Report issue |
Web Explorer#6107 Bundle Size — 366.7KiB (0%).a0ca8ef(current) vs 04f2c39 main#6100(baseline) Bundle metrics
Bundle size by type
|
| Current #6107 |
Baseline #6100 |
|
|---|---|---|
240.68KiB |
240.68KiB |
|
93.8KiB |
93.8KiB |
|
32.22KiB |
32.22KiB |
Bundle analysis report Branch feat/lazy-snapshot-create Project dashboard
Generated by RelativeCI Documentation Report issue
62038ad to
909a542
Compare
909a542 to
212cc5c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (3)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_comments.js (1)
2-18: Consistent registry-based snapshot registration.Looks good; same DCE/registry export considerations as noted in transform-imports-css-scoped-modules.js.
packages/react/runtime/src/snapshot.ts (1)
287-294: Verify that creator actually registers the snapshot.After invoking
snapshotCreatorMap[type](), there's no guarantee the creator successfully registered the snapshot insnapshotManager.values. The subsequentget(type)!on line 294 could still returnundefined, leading to runtime errors later when accessingthis.__snapshot_def.Consider adding verification after the creator call:
if (!snapshotManager.values.has(type) && type !== 'div') { if (snapshotCreatorMap[type]) { snapshotCreatorMap[type](); + // Verify creator actually registered the snapshot + if (!snapshotManager.values.has(type)) { + throw new Error(`Snapshot creator for '${type}' did not register the snapshot`); + } } else { throw new Error('Snapshot not found: ' + type); } } this.__snapshot_def = snapshotManager.values.get(type)!;packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_ref.js (1)
31-31: Verify that the null slot argument was actually fixed.A previous critical review flagged this
nullslot argument, stating that the runtime expects an array and will crash onslot.length. That comment was marked as addressed in commit 2ec11ac, but the test snapshot still showsnullhere.Please verify whether:
- The fix was reverted or the snapshot needs regeneration, or
- The runtime was updated to handle
nullslots safelyRun this script to check how the runtime handles null slots:
#!/bin/bash # Description: Check runtime handling of null slot arguments # Search for slot.length or slot indexing in the runtime rg -n -A3 -B3 --type ts 'slot\.length|slot\[' packages/react/runtime/src/ # Search for createSnapshot implementation to see parameter handling ast-grep --pattern 'function createSnapshot($$$) { $$$ }'
🧹 Nitpick comments (2)
packages/react/runtime/__test__/css/scoped-lazy-bundle.test.jsx (1)
12-19: Good setup/teardown for global mutation.Restoring globDynamicComponentEntry avoids cross-test leakage.
You can simplify with Vitest globals:
-import { expect, it, beforeEach, afterEach } from 'vitest'; +import { expect, it, beforeEach, afterEach, vi } from 'vitest'; -let prevEntryName; -beforeEach(() => { - prevEntryName = globalThis.globDynamicComponentEntry; - globalThis.globDynamicComponentEntry = 'FOO'; -}); -afterEach(() => { - globalThis.globDynamicComponentEntry = prevEntryName; -}); +beforeEach(() => { + vi.stubGlobal('globDynamicComponentEntry', 'FOO'); +}); +afterEach(() => { + vi.unstubAllGlobals(); +});packages/react/transform/__test__/css/__snapshots__/transform-imports-css-scoped-modules.js (1)
7-18: Code migration is correct; runtime contract verified.The snapshotCreatorMap is correctly exported as a plain object (
Record<string, () => string>), so bracket assignment works as intended. No.set()method calls are used, confirming the pattern is consistent throughout the codebase.Consider the optional refactor to improve tree-shaking behavior:
-ReactLynx.snapshotCreatorMap[__snapshot_2d408_test_1] = ()=>ReactLynx.createSnapshot(/*...*/); +/*#__PURE__*/ ReactLynx.registerSnapshot(__snapshot_2d408_test_1, () => ReactLynx.createSnapshot(/*...*/));This helper function would reduce side-effect footprint for bundler optimization.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
packages/web-platform/web-tests/tests/__snapshots__/server.vitest.spec.ts.snapis excluded by!**/*.snap
📒 Files selected for processing (94)
.changeset/full-brooms-care.md(1 hunks)packages/react/runtime/__test__/basic.test.jsx(1 hunks)packages/react/runtime/__test__/css/remove-scoped-lazy-bundle.test.jsx(1 hunks)packages/react/runtime/__test__/css/scoped-lazy-bundle.test.jsx(1 hunks)packages/react/runtime/__test__/debug/jsx-twice.test.jsx(1 hunks)packages/react/runtime/__test__/debug/printSnapshot.test.jsx(1 hunks)packages/react/runtime/__test__/delayed-lifecycle-events.test.jsx(2 hunks)packages/react/runtime/__test__/element.test.jsx(1 hunks)packages/react/runtime/__test__/hydrate.test.jsx(4 hunks)packages/react/runtime/__test__/lifecycle.test.jsx(3 hunks)packages/react/runtime/__test__/lifecycle/reload.test.jsx(15 hunks)packages/react/runtime/__test__/list.test.jsx(61 hunks)packages/react/runtime/__test__/lynx/suspense.test.jsx(2 hunks)packages/react/runtime/__test__/lynx/timing.test.jsx(4 hunks)packages/react/runtime/__test__/preact.test.jsx(12 hunks)packages/react/runtime/__test__/renderToOpcodes.test.jsx(13 hunks)packages/react/runtime/__test__/snapshot/event.test.jsx(4 hunks)packages/react/runtime/__test__/snapshot/ref.test.jsx(10 hunks)packages/react/runtime/__test__/snapshot/workletEvent.test.jsx(4 hunks)packages/react/runtime/__test__/snapshot/workletRef.test.jsx(1 hunks)packages/react/runtime/__test__/snapshotPatch.test.jsx(15 hunks)packages/react/runtime/__test__/ssr.test.jsx(10 hunks)packages/react/runtime/lazy/internal.js(1 hunks)packages/react/runtime/src/backgroundSnapshot.ts(1 hunks)packages/react/runtime/src/internal.ts(1 hunks)packages/react/runtime/src/lifecycle/patch/snapshotPatchApply.ts(2 hunks)packages/react/runtime/src/snapshot.ts(3 hunks)packages/react/testing-library/src/__tests__/act.test.jsx(4 hunks)packages/react/testing-library/src/__tests__/alog.test.jsx(2 hunks)packages/react/testing-library/src/__tests__/end-to-end.test.jsx(4 hunks)packages/react/testing-library/src/__tests__/lazy-bundle/index.test.jsx(2 hunks)packages/react/testing-library/src/__tests__/list.test.jsx(15 hunks)packages/react/testing-library/src/__tests__/lynx.test.jsx(1 hunks)packages/react/transform/__test__/css/__snapshots__/transform-all-css-scoped-all.js(1 hunks)packages/react/transform/__test__/css/__snapshots__/transform-all-css-scoped-modules.js(1 hunks)packages/react/transform/__test__/css/__snapshots__/transform-all-css-scoped-none.js(1 hunks)packages/react/transform/__test__/css/__snapshots__/transform-imports-css-scoped-all.js(1 hunks)packages/react/transform/__test__/css/__snapshots__/transform-imports-css-scoped-modules.js(1 hunks)packages/react/transform/__test__/css/__snapshots__/transform-imports-css-scoped-none.js(1 hunks)packages/react/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-all-lazy-bundle.js(1 hunks)packages/react/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-all.js(1 hunks)packages/react/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-modules-lazy-bundle.js(1 hunks)packages/react/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-modules.js(1 hunks)packages/react/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-none-lazy-bundle.js(1 hunks)packages/react/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-none.js(1 hunks)packages/react/transform/__test__/css/__snapshots__/transform-jsx-defaults.js(1 hunks)packages/react/transform/__test__/fixture.spec.js(6 hunks)packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js(2 hunks)packages/react/transform/crates/swc_plugin_snapshot/lib.rs(3 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling_jsx.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling_jsx_dev.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_event.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_expr_container.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_expr_container_with_static_sibling.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static_snapshot_extract.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static_snapshot_extract_it.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list_toplevel.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list_with_fragment.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_ref.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_spread.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_timing_flag.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_comments.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_map_jsx.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_new_line.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_self_close.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/gesture.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/inline_style_literal.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/inline_style_literal_unknown_property.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/mode_development_spread.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_component.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_element.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_element_dev.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_escape_newline_character.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component_without_css_id.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_without_css_id.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_inject_implicit_flatten.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_dynamic_inline_style.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_inline_style.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_wrap_dynamic_key.js(1 hunks)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/worklet.js(1 hunks)packages/webpack/react-refresh-webpack-plugin/test/hotCases/hook/useContext/__snapshot__/rspack/1.snap.txt(2 hunks)packages/webpack/react-refresh-webpack-plugin/test/hotCases/hook/useState/__snapshot__/rspack/1.snap.txt(2 hunks)packages/webpack/react-refresh-webpack-plugin/test/hotCases/jsx/basic/__snapshot__/rspack/1.snap.txt(2 hunks)packages/webpack/react-refresh-webpack-plugin/test/hotCases/jsx/basic/__snapshot__/rspack/2.snap.txt(2 hunks)packages/webpack/react-refresh-webpack-plugin/test/hotCases/jsx/recovery/__snapshot__/rspack/2.snap.txt(2 hunks)packages/webpack/react-refresh-webpack-plugin/test/hotCases/jsx/value/__snapshot__/rspack/1.snap.txt(2 hunks)packages/webpack/react-refresh-webpack-plugin/test/hotCases/jsx/value/__snapshot__/rspack/2.snap.txt(2 hunks)packages/webpack/react-webpack-plugin/test/cases/code-splitting/amd-runtime-lazy-bundle-production/index.jsx(2 hunks)
✅ Files skipped from review due to trivial changes (2)
- packages/react/runtime/test/element.test.jsx
- packages/react/runtime/test/list.test.jsx
🚧 Files skipped from review as they are similar to previous changes (33)
- packages/react/runtime/test/delayed-lifecycle-events.test.jsx
- packages/react/testing-library/src/tests/alog.test.jsx
- packages/react/testing-library/src/tests/list.test.jsx
- packages/react/transform/crates/swc_plugin_snapshot/tests/swc_snapshots/lib.rs/should_extract_css_id_dynamic_component_without_css_id.js
- packages/webpack/react-refresh-webpack-plugin/test/hotCases/hook/useContext/snapshot/rspack/1.snap.txt
- packages/react/transform/crates/swc_plugin_snapshot/tests/swc_snapshots/lib.rs/should_escape_newline_character.js
- packages/react/transform/test/css/snapshots/transform-jsx-css-scoped-all.js
- packages/react/transform/crates/swc_plugin_snapshot/tests/swc_snapshots/lib.rs/basic_list_toplevel.js
- packages/react/testing-library/src/tests/end-to-end.test.jsx
- packages/react/runtime/test/debug/printSnapshot.test.jsx
- packages/react/transform/crates/swc_plugin_snapshot/tests/swc_snapshots/lib.rs/basic_full_static_snapshot_extract_it.js
- packages/react/transform/test/fixture.spec.js
- packages/webpack/react-refresh-webpack-plugin/test/hotCases/jsx/basic/snapshot/rspack/1.snap.txt
- packages/react/transform/crates/swc_plugin_snapshot/tests/swc_snapshots/lib.rs/basic_full_static_snapshot_extract.js
- packages/react/runtime/test/hydrate.test.jsx
- packages/react/transform/test/css/snapshots/transform-jsx-css-scoped-all-lazy-bundle.js
- packages/react/runtime/test/lynx/timing.test.jsx
- packages/react/runtime/test/lifecycle/reload.test.jsx
- packages/react/runtime/test/basic.test.jsx
- packages/react/runtime/test/css/remove-scoped-lazy-bundle.test.jsx
- packages/react/transform/crates/swc_plugin_snapshot/tests/swc_snapshots/lib.rs/should_inject_implicit_flatten.js
- packages/react/transform/test/css/snapshots/transform-imports-css-scoped-none.js
- packages/react/runtime/test/snapshotPatch.test.jsx
- packages/react/transform/crates/swc_plugin_snapshot/tests/swc_snapshots/lib.rs/full_static_children_map_jsx.js
- packages/react/runtime/test/snapshot/workletEvent.test.jsx
- packages/react/transform/crates/swc_plugin_snapshot/tests/swc_snapshots/lib.rs/basic_full_static.js
- packages/webpack/react-webpack-plugin/test/cases/code-splitting/amd-runtime-lazy-bundle-production/index.jsx
- packages/react/transform/crates/swc_plugin_snapshot/tests/swc_snapshots/lib.rs/mode_development_spread.js
- packages/react/transform/test/css/snapshots/transform-imports-css-scoped-all.js
- packages/webpack/react-refresh-webpack-plugin/test/hotCases/jsx/recovery/snapshot/rspack/2.snap.txt
- packages/webpack/react-refresh-webpack-plugin/test/hotCases/jsx/basic/snapshot/rspack/2.snap.txt
- packages/react/transform/crates/swc_plugin_snapshot/tests/swc_snapshots/lib.rs/basic_expr_container_with_static_sibling.js
- packages/react/transform/crates/swc_plugin_snapshot/tests/swc_snapshots/lib.rs/basic_component_with_static_sibling_jsx.js
🧰 Additional context used
📓 Path-based instructions (1)
.changeset/*.md
📄 CodeRabbit inference engine (AGENTS.md)
For contributions, generate and commit a Changeset describing your changes
Files:
.changeset/full-brooms-care.md
🧠 Learnings (6)
📚 Learning: 2025-09-18T04:43:54.426Z
Learnt from: gaoachao
PR: lynx-family/lynx-stack#1771
File: packages/react/transform/tests/__swc_snapshots__/src/swc_plugin_snapshot/mod.rs/basic_component_with_static_sibling.js:2-2
Timestamp: 2025-09-18T04:43:54.426Z
Learning: In the lynx-family/lynx-stack repository, the `add_pure_comment` function in packages/react/transform/src/swc_plugin_compat/mod.rs (around lines 478-482) is specifically for `wrapWithLynxComponent` calls, not `createSnapshot` calls. The PURE comment injection for `createSnapshot` is handled separately in swc_plugin_snapshot/mod.rs.
Applied to files:
packages/react/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-none.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_comments.jspackages/webpack/react-refresh-webpack-plugin/test/hotCases/hook/useState/__snapshot__/rspack/1.snap.txtpackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_new_line.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_timing_flag.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_self_close.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_dynamic_inline_style.jspackages/react/transform/__test__/css/__snapshots__/transform-jsx-defaults.jspackages/react/transform/__test__/css/__snapshots__/transform-all-css-scoped-all.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_expr_container.jspackages/react/transform/__test__/css/__snapshots__/transform-all-css-scoped-modules.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_event.jspackages/react/transform/__test__/css/__snapshots__/transform-all-css-scoped-none.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/inline_style_literal.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_component.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_inline_style.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_element_dev.jspackages/react/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-modules.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_ref.jspackages/react/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-none-lazy-bundle.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_without_css_id.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_spread.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/inline_style_literal_unknown_property.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list_with_fragment.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling_jsx_dev.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.jspackages/react/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-modules-lazy-bundle.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id.jspackages/webpack/react-refresh-webpack-plugin/test/hotCases/jsx/value/__snapshot__/rspack/2.snap.txtpackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_wrap_dynamic_key.jspackages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/worklet.jspackages/webpack/react-refresh-webpack-plugin/test/hotCases/jsx/value/__snapshot__/rspack/1.snap.txtpackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_element.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/gesture.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list.js
📚 Learning: 2025-08-12T16:09:32.413Z
Learnt from: colinaaa
PR: lynx-family/lynx-stack#1497
File: packages/react/transform/tests/__swc_snapshots__/src/swc_plugin_snapshot/mod.rs/basic_full_static.js:9-10
Timestamp: 2025-08-12T16:09:32.413Z
Learning: In the Lynx stack, functions prefixed with `__` that are called in transformed code may be injected globally by the Lynx Engine at runtime rather than exported from the React runtime package. For example, `__CreateFrame` is injected globally by the Lynx Engine, not exported from lynx-js/react.
Applied to files:
packages/react/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-none.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_comments.jspackages/webpack/react-refresh-webpack-plugin/test/hotCases/hook/useState/__snapshot__/rspack/1.snap.txtpackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_new_line.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_timing_flag.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_self_close.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_dynamic_inline_style.jspackages/react/transform/__test__/css/__snapshots__/transform-jsx-defaults.jspackages/react/transform/__test__/css/__snapshots__/transform-all-css-scoped-all.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_expr_container.jspackages/react/transform/__test__/css/__snapshots__/transform-all-css-scoped-modules.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_event.jspackages/react/transform/__test__/css/__snapshots__/transform-all-css-scoped-none.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/inline_style_literal.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_component.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_inline_style.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_element_dev.jspackages/react/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-modules.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_ref.jspackages/react/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-none-lazy-bundle.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_without_css_id.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_spread.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/inline_style_literal_unknown_property.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling_jsx_dev.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.jspackages/react/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-modules-lazy-bundle.jspackages/webpack/react-refresh-webpack-plugin/test/hotCases/jsx/value/__snapshot__/rspack/2.snap.txtpackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_wrap_dynamic_key.jspackages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/worklet.jspackages/webpack/react-refresh-webpack-plugin/test/hotCases/jsx/value/__snapshot__/rspack/1.snap.txtpackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_element.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/gesture.js
📚 Learning: 2025-09-18T04:43:54.426Z
Learnt from: gaoachao
PR: lynx-family/lynx-stack#1771
File: packages/react/transform/tests/__swc_snapshots__/src/swc_plugin_snapshot/mod.rs/basic_component_with_static_sibling.js:2-2
Timestamp: 2025-09-18T04:43:54.426Z
Learning: In packages/react/transform/src/swc_plugin_compat/mod.rs, the `add_pure_comment` function at lines 478-482 is specifically for `wrapWithLynxComponent` calls, not `createSnapshot` calls. The PURE comment injection for `createSnapshot` is handled separately in swc_plugin_snapshot/mod.rs. These are two distinct code paths that should be treated differently.
Applied to files:
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_comments.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_new_line.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_timing_flag.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_self_close.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_dynamic_inline_style.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_expr_container.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_event.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/inline_style_literal.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component.jspackages/react/transform/crates/swc_plugin_snapshot/lib.rspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_component.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_inline_style.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_element_dev.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_ref.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_without_css_id.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_spread.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/inline_style_literal_unknown_property.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list_with_fragment.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling_jsx_dev.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_wrap_dynamic_key.jspackages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/worklet.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_element.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/gesture.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list.js
📚 Learning: 2025-08-27T12:42:01.095Z
Learnt from: upupming
PR: lynx-family/lynx-stack#1616
File: packages/webpack/cache-events-webpack-plugin/test/cases/not-cache-events/lazy-bundle/index.js:3-3
Timestamp: 2025-08-27T12:42:01.095Z
Learning: In webpack, properties like __webpack_require__.lynx_ce are injected during compilation/build time when webpack processes modules and generates bundles, not at runtime when dynamic imports execute. Tests for such properties don't need to wait for dynamic imports to complete.
Applied to files:
packages/webpack/react-refresh-webpack-plugin/test/hotCases/hook/useState/__snapshot__/rspack/1.snap.txtpackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_element_dev.jspackages/webpack/react-refresh-webpack-plugin/test/hotCases/jsx/value/__snapshot__/rspack/2.snap.txtpackages/webpack/react-refresh-webpack-plugin/test/hotCases/jsx/value/__snapshot__/rspack/1.snap.txt
📚 Learning: 2025-09-23T08:54:39.966Z
Learnt from: upupming
PR: lynx-family/lynx-stack#1670
File: packages/webpack/css-extract-webpack-plugin/test/hotCases/hot/hot-update-json/dual-thread/__snapshot__/index.css:6-8
Timestamp: 2025-09-23T08:54:39.966Z
Learning: In the lynx-stack CSS extract webpack plugin tests, many test fixture CSS files intentionally use invalid CSS syntax like `color: 'red';` with quoted values. The snapshots correctly reflect this invalid CSS from the source fixtures. To fix CSS validation issues, the source fixture files should be updated first, then snapshots regenerated, rather than manually editing snapshots.
Applied to files:
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_dynamic_inline_style.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_inline_style.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_without_css_id.jspackages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id.js
📚 Learning: 2025-08-21T07:21:51.621Z
Learnt from: upupming
PR: lynx-family/lynx-stack#1562
File: packages/react/transform/src/swc_plugin_snapshot/jsx_helpers.rs:261-283
Timestamp: 2025-08-21T07:21:51.621Z
Learning: In packages/react/transform/src/swc_plugin_snapshot/jsx_helpers.rs, the team prefers to keep the original unreachable! logic for JSXSpreadChild in jsx_is_children_full_dynamic function rather than implementing defensive error handling.
Applied to files:
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_spread.js
🧬 Code graph analysis (39)
packages/react/runtime/src/backgroundSnapshot.ts (1)
packages/react/runtime/src/snapshot.ts (2)
snapshotManager(58-123)snapshotCreatorMap(138-138)
packages/react/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-none.js (3)
packages/react/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-all-lazy-bundle.js (1)
__snapshot_2d408_test_1(3-3)packages/react/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-all.js (1)
__snapshot_2d408_test_1(3-3)packages/react/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-modules.js (1)
__snapshot_2d408_test_1(3-3)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling.js (3)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (15)
__snapshot_da39a_test_1(2-2)pageId(4-4)pageId(17-17)pageId(25-25)pageId(33-33)pageId(51-51)pageId(64-64)pageId(78-78)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling_jsx.js (6)
__snapshot_da39a_test_1(3-3)pageId(5-5)el(6-6)el1(7-7)el2(9-9)el3(11-11)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_comments.js (1)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_new_line.js (2)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (15)
__snapshot_da39a_test_1(2-2)pageId(4-4)pageId(17-17)pageId(25-25)pageId(33-33)pageId(51-51)pageId(64-64)pageId(78-78)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_timing_flag.js (2)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (15)
__snapshot_da39a_test_1(2-2)pageId(4-4)pageId(17-17)pageId(25-25)pageId(33-33)pageId(51-51)pageId(64-64)pageId(78-78)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_event.js (5)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)el1(6-6)el2(8-8)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_self_close.js (2)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (15)
__snapshot_da39a_test_1(2-2)pageId(4-4)pageId(17-17)pageId(25-25)pageId(33-33)pageId(51-51)pageId(64-64)pageId(78-78)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_dynamic_inline_style.js (2)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (1)
__snapshot_da39a_test_1(2-2)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (1)
__snapshot_da39a_test_1(2-2)
packages/react/transform/__test__/css/__snapshots__/transform-all-css-scoped-all.js (3)
packages/react/transform/__test__/css/__snapshots__/transform-all-css-scoped-modules.js (1)
__snapshot_2d408_test_1(5-5)packages/react/transform/__test__/css/__snapshots__/transform-imports-css-scoped-all.js (1)
__snapshot_2d408_test_1(7-7)packages/react/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-all.js (1)
__snapshot_2d408_test_1(3-3)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_expr_container.js (3)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (15)
__snapshot_da39a_test_1(2-2)pageId(4-4)pageId(17-17)pageId(25-25)pageId(33-33)pageId(51-51)pageId(64-64)pageId(78-78)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_expr_container_with_static_sibling.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)
packages/react/runtime/src/lifecycle/patch/snapshotPatchApply.ts (1)
packages/react/runtime/src/snapshot.ts (1)
snapshotManager(58-123)
packages/react/transform/__test__/css/__snapshots__/transform-all-css-scoped-modules.js (2)
packages/react/transform/__test__/css/__snapshots__/transform-all-css-scoped-all.js (3)
__snapshot_2d408_test_1(5-5)pageId(7-7)el(8-8)packages/react/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-modules.js (1)
__snapshot_2d408_test_1(3-3)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_event.js (2)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (1)
__snapshot_da39a_test_1(2-2)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (1)
__snapshot_da39a_test_1(2-2)
packages/react/transform/__test__/css/__snapshots__/transform-all-css-scoped-none.js (3)
packages/react/transform/__test__/css/__snapshots__/transform-all-css-scoped-all.js (3)
__snapshot_2d408_test_1(5-5)pageId(7-7)el(8-8)packages/react/transform/__test__/css/__snapshots__/transform-imports-css-scoped-all.js (3)
__snapshot_2d408_test_1(7-7)pageId(9-9)el(10-10)packages/react/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-all.js (9)
__snapshot_2d408_test_1(3-3)pageId(5-5)pageId(14-14)pageId(26-26)pageId(39-39)el(6-6)el(15-15)el(27-27)el(40-40)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/inline_style_literal.js (2)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (15)
__snapshot_da39a_test_1(2-2)pageId(4-4)pageId(17-17)pageId(25-25)pageId(33-33)pageId(51-51)pageId(64-64)pageId(78-78)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component.js (1)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component_without_css_id.js (3)
__snapshot_da39a_test_2(12-12)__snapshot_da39a_test_3(29-29)__snapshot_da39a_test_4(50-50)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_component.js (2)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (15)
__snapshot_da39a_test_1(2-2)pageId(4-4)pageId(17-17)pageId(25-25)pageId(33-33)pageId(51-51)pageId(64-64)pageId(78-78)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_inline_style.js (2)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (15)
__snapshot_da39a_test_1(2-2)pageId(4-4)pageId(17-17)pageId(25-25)pageId(33-33)pageId(51-51)pageId(64-64)pageId(78-78)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)
packages/react/runtime/src/snapshot.ts (1)
packages/react/runtime/src/internal.ts (2)
snapshotCreatorMap(27-27)snapshotManager(26-26)
packages/react/transform/__test__/css/__snapshots__/transform-imports-css-scoped-modules.js (1)
packages/react/transform/__test__/css/__snapshots__/transform-all-css-scoped-all.js (3)
__snapshot_2d408_test_1(5-5)pageId(7-7)el(8-8)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_element_dev.js (2)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (15)
__snapshot_da39a_test_1(2-2)pageId(4-4)pageId(17-17)pageId(25-25)pageId(33-33)pageId(51-51)pageId(64-64)pageId(78-78)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_event.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)
packages/react/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-modules.js (4)
packages/react/transform/__test__/css/__snapshots__/transform-all-css-scoped-all.js (3)
__snapshot_2d408_test_1(5-5)pageId(7-7)el(8-8)packages/react/transform/__test__/css/__snapshots__/transform-all-css-scoped-modules.js (3)
__snapshot_2d408_test_1(5-5)pageId(7-7)el(8-8)packages/react/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-all-lazy-bundle.js (11)
__snapshot_2d408_test_1(3-3)pageId(5-5)pageId(14-14)pageId(26-26)pageId(39-39)el(6-6)el(15-15)el(27-27)el(40-40)__snapshot_2d408_test_2(12-12)el1(16-16)packages/react/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-none.js (3)
__snapshot_2d408_test_1(3-3)__snapshot_2d408_test_2(12-12)el1(16-16)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_ref.js (1)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (8)
__snapshot_da39a_test_1(2-2)pageId(4-4)pageId(17-17)pageId(25-25)pageId(33-33)pageId(51-51)pageId(64-64)pageId(78-78)
packages/react/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-none-lazy-bundle.js (1)
packages/react/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-all-lazy-bundle.js (13)
__snapshot_2d408_test_1(3-3)pageId(5-5)pageId(14-14)pageId(26-26)pageId(39-39)el(6-6)el(15-15)el(27-27)el(40-40)__snapshot_2d408_test_2(12-12)el1(16-16)__snapshot_2d408_test_3(24-24)__snapshot_2d408_test_4(37-37)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_without_css_id.js (3)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (16)
__snapshot_da39a_test_1(2-2)pageId(4-4)pageId(17-17)pageId(25-25)pageId(33-33)pageId(51-51)pageId(64-64)pageId(78-78)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)__snapshot_da39a_test_2(15-15)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component.js (1)
__snapshot_da39a_test_2(14-14)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_spread.js (3)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (15)
__snapshot_da39a_test_1(2-2)pageId(4-4)pageId(17-17)pageId(25-25)pageId(33-33)pageId(51-51)pageId(64-64)pageId(78-78)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling.js (5)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)el1(6-6)el2(8-8)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/inline_style_literal_unknown_property.js (1)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list_with_fragment.js (1)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (5)
__snapshot_da39a_test_3(23-23)__snapshot_da39a_test_4(31-31)__snapshot_da39a_test_2(15-15)__snapshot_da39a_test_5(49-49)__snapshot_da39a_test_1(2-2)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling_jsx_dev.js (4)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (1)
__snapshot_da39a_test_1(2-2)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (1)
__snapshot_da39a_test_1(2-2)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling.js (1)
__snapshot_da39a_test_1(2-2)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling_jsx.js (1)
__snapshot_da39a_test_1(3-3)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (15)
__snapshot_da39a_test_1(2-2)pageId(4-4)pageId(17-17)pageId(25-25)pageId(33-33)pageId(51-51)pageId(64-64)pageId(78-78)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling_jsx.js (3)
__snapshot_da39a_test_1(3-3)pageId(5-5)el(6-6)
packages/react/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-modules-lazy-bundle.js (2)
packages/react/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-all-lazy-bundle.js (13)
__snapshot_2d408_test_1(3-3)pageId(5-5)pageId(14-14)pageId(26-26)pageId(39-39)el(6-6)el(15-15)el(27-27)el(40-40)__snapshot_2d408_test_2(12-12)el1(16-16)__snapshot_2d408_test_3(24-24)__snapshot_2d408_test_4(37-37)packages/react/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-modules.js (9)
__snapshot_2d408_test_1(3-3)pageId(5-5)pageId(14-14)el(6-6)el(15-15)__snapshot_2d408_test_2(12-12)el1(16-16)__snapshot_2d408_test_3(24-24)__snapshot_2d408_test_4(37-37)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id.js (4)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (18)
__snapshot_da39a_test_1(2-2)pageId(4-4)pageId(17-17)pageId(25-25)pageId(33-33)pageId(51-51)pageId(64-64)pageId(78-78)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)__snapshot_da39a_test_2(15-15)__snapshot_da39a_test_3(23-23)__snapshot_da39a_test_4(31-31)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component.js (3)
__snapshot_da39a_test_2(14-14)__snapshot_da39a_test_3(31-31)__snapshot_da39a_test_4(52-52)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_wrap_dynamic_key.js (2)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (1)
__snapshot_da39a_test_2(15-15)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list.js (1)
__snapshot_da39a_test_2(12-12)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (3)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_event.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list.js (9)
__snapshot_da39a_test_1(33-33)pageId(4-4)pageId(14-14)pageId(27-27)pageId(35-35)el(5-5)el(15-15)el(28-28)el(36-36)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/worklet.js (2)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (15)
__snapshot_da39a_test_1(2-2)pageId(4-4)pageId(17-17)pageId(25-25)pageId(33-33)pageId(51-51)pageId(64-64)pageId(78-78)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_event.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)
packages/react/runtime/__test__/css/scoped-lazy-bundle.test.jsx (1)
packages/react/runtime/__test__/css/remove-scoped-lazy-bundle.test.jsx (1)
prevEntryName(8-8)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_element.js (3)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (15)
__snapshot_da39a_test_1(2-2)pageId(4-4)pageId(17-17)pageId(25-25)pageId(33-33)pageId(51-51)pageId(64-64)pageId(78-78)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static.js (3)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/gesture.js (1)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_event.js (5)
__snapshot_da39a_test_1(2-2)pageId(4-4)el(5-5)el1(6-6)el2(8-8)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list.js (3)
packages/react/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js (11)
__snapshot_da39a_test_3(23-23)el(5-5)el(18-18)el(26-26)el(34-34)el(52-52)el(65-65)el(79-79)__snapshot_da39a_test_2(15-15)__snapshot_da39a_test_4(31-31)__snapshot_da39a_test_1(2-2)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list_toplevel.js (3)
__snapshot_da39a_test_3(13-13)__snapshot_da39a_test_2(2-2)__snapshot_da39a_test_1(24-24)packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list_with_fragment.js (4)
__snapshot_da39a_test_3(2-2)__snapshot_da39a_test_2(18-18)__snapshot_da39a_test_4(10-10)__snapshot_da39a_test_1(39-39)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: build / Build (Ubuntu)
- GitHub Check: build / Build (Windows)
- GitHub Check: test-rust / Test (Ubuntu)
- GitHub Check: test-rust / clippy
|
@hzy Sorry for that, tests are passed now! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/react/transform/__test__/css/__snapshots__/transform-imports-css-scoped-all.js (1)
7-23: Fix source fixture:styles2is undefined and never imported incss-scope.spec.jsline 75.The snapshot correctly reflects the broken source input. Either import/define
styles2in the test fixture or remove the reference.Location:
packages/react/transform/__test__/css/css-scope.spec.jsline 75.
♻️ Duplicate comments (2)
packages/react/runtime/src/snapshot.ts (1)
281-289: Add a second guard after invoking creator to avoid undefined __snapshot_def.If a creator exists but fails to register,
snapshotManager.values.get(type)!becomes undefined and later logic crashes. Re-check and throw a clear error.- if (!snapshotManager.values.has(type) && type !== 'div') { - if (snapshotCreatorMap[type]) { - snapshotCreatorMap[type](type); - } else { - throw new Error('Snapshot not found: ' + type); - } - } - this.__snapshot_def = snapshotManager.values.get(type)!; + if (!snapshotManager.values.has(type) && type !== 'div') { + const creator = snapshotCreatorMap[type]; + if (creator) { + creator(type); + } else { + throw new Error(`Snapshot not found or not registered: ${type}`); + } + } + const def = snapshotManager.values.get(type); + if (!def && type !== 'div') { + throw new Error(`Snapshot not found or not registered: ${type}`); + } + this.__snapshot_def = def!;packages/react/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-all-lazy-bundle.js (1)
50-50: Same trailing comma expression as in transform-jsx-css-scoped-none-lazy-bundle.js.This file has the identical
Foo, App;expression that appears to be dead code. Please verify its purpose across these test snapshots.
🧹 Nitpick comments (16)
packages/webpack/react-refresh-webpack-plugin/test/hotCases/jsx/recovery/__snapshot__/rspack/2.snap.txt (1)
50-63: Registry wiring LGTM; consider avoiding param shadowing in codegen.
The factory parameter name equals the outer const (e.g., __snapshot_4953c_b7a87_1). It’s valid but mildly confusing. Prefer a neutral name like uniqId in the generated code.packages/react/runtime/__test__/snapshot/ref.test.jsx (1)
120-121: Inline snapshots updated for lazy snapshot keys.
Updates look consistent with the registry-based approach. Consider adding one negative test to assert the dev error when a snapshot key is referenced without a registered factory (ensures BackgroundSnapshotInstance path remains descriptive).Also applies to: 205-206, 500-500, 941-942, 1019-1019, 1444-1454, 1526-1536, 1581-1591, 1684-1684, 1962-1964
packages/react/transform/__test__/css/__snapshots__/transform-all-css-scoped-none.js (1)
5-12: Transform output matches registry pattern; optional param rename.
Looks good. For clarity in generated code, consider using a neutral parameter name (e.g., uniqId) instead of shadowing the outer constant.packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_component.js (1)
2-9: Looks good; rename param to avoid shadowing.Shadowing the const with the arrow param impairs readability. Prefer
uniqIdfor the parameter.-ReactLynx.snapshotCreatorMap[__snapshot_da39a_test_1] = (__snapshot_da39a_test_1)=>ReactLynx.createSnapshot(__snapshot_da39a_test_1, function() { +ReactLynx.snapshotCreatorMap[__snapshot_da39a_test_1] = (uniqId)=>ReactLynx.createSnapshot(uniqId, function() {Note: PURE comments are not required here; createSnapshot’s PURE handling is separate from wrapWithLynxComponent. Based on learnings.
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_new_line.js (1)
2-18: Static snapshot wiring LGTM; minor naming nit.Registration is correct (static create, no updates/slots). Rename param for clarity.
-ReactLynx.snapshotCreatorMap[__snapshot_da39a_test_1] = (__snapshot_da39a_test_1)=>ReactLynx.createSnapshot(__snapshot_da39a_test_1, function() { +ReactLynx.snapshotCreatorMap[__snapshot_da39a_test_1] = (uniqId)=>ReactLynx.createSnapshot(uniqId, function() {packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_element.js (1)
3-10: Registration correct; rename param for readability.Slot choice and args look right. Avoid shadowing by renaming the parameter.
-ReactLynx.snapshotCreatorMap[__snapshot_da39a_test_1] = (__snapshot_da39a_test_1)=>ReactLynx.createSnapshot(__snapshot_da39a_test_1, function() { +ReactLynx.snapshotCreatorMap[__snapshot_da39a_test_1] = (uniqId)=>ReactLynx.createSnapshot(uniqId, function() {packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/inline_style_literal_unknown_property.js (1)
2-10: LGTM; keep param names clear.Wiring matches intent for the style test. Rename arrow param for clarity.
-ReactLynx.snapshotCreatorMap[__snapshot_da39a_test_1] = (__snapshot_da39a_test_1)=>ReactLynx.createSnapshot(__snapshot_da39a_test_1, function() { +ReactLynx.snapshotCreatorMap[__snapshot_da39a_test_1] = (uniqId)=>ReactLynx.createSnapshot(uniqId, function() {packages/react/runtime/src/lifecycle/patch/snapshotPatchApply.ts (1)
19-19: Consider a safer registry type for creators (Map or null-prototype object)snapshotCreatorMap is a plain object (per snapshot.ts). While keys are controlled, prefer:
- Map<string, (uniqId: string) => string>, or
- Object.create(null) for a prototype-less record.
This reduces accidental collisions with inherited props and clarifies intent.
Proposed in snapshot.ts:
-export let snapshotCreatorMap: Record<string, (uniqId: string) => string> = {}; +export const snapshotCreatorMap: Map<string, (uniqId: string) => string> = new Map();And here:
- snapshotCreatorMap[uniqID] = evaluate(...); + snapshotCreatorMap.set(uniqID, evaluate(...));If changing to Map is too broad for now, initialize with Object.create(null):
-export let snapshotCreatorMap: Record<string, (uniqId: string) => string> = {}; +export let snapshotCreatorMap: Record<string, (uniqId: string) => string> = Object.create(null);packages/react/transform/__test__/css/__snapshots__/transform-all-css-scoped-all.js (1)
5-12: Rename the factory param to uniqId for claritySame shadowing pattern; prefer a distinct param and forward it.
-ReactLynx.snapshotCreatorMap[__snapshot_2d408_test_1] = (__snapshot_2d408_test_1)=>ReactLynx.createSnapshot(__snapshot_2d408_test_1, function() { +ReactLynx.snapshotCreatorMap[__snapshot_2d408_test_1] = (uniqId)=>ReactLynx.createSnapshot(uniqId, function() {packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_inline_style.js (2)
2-10: Use uniqId instead of a shadowed param nameRename the param to avoid shadowing the outer const.
-ReactLynx.snapshotCreatorMap[__snapshot_da39a_test_1] = (__snapshot_da39a_test_1)=>ReactLynx.createSnapshot(__snapshot_da39a_test_1, function() { +ReactLynx.snapshotCreatorMap[__snapshot_da39a_test_1] = (uniqId)=>ReactLynx.createSnapshot(uniqId, function() {
12-20: Same here: avoid shadowing for consistencyApply the same param rename in this block.
-ReactLynx.snapshotCreatorMap[__snapshot_da39a_test_2] = (__snapshot_da39a_test_2)=>ReactLynx.createSnapshot(__snapshot_da39a_test_2, function() { +ReactLynx.snapshotCreatorMap[__snapshot_da39a_test_2] = (uniqId)=>ReactLynx.createSnapshot(uniqId, function() {packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_comments.js (1)
2-18: Avoid param/const name collision in creator registrationRename param to uniqId for readability/debuggability.
-ReactLynx.snapshotCreatorMap[__snapshot_da39a_test_1] = (__snapshot_da39a_test_1)=>ReactLynx.createSnapshot(__snapshot_da39a_test_1, function() { +ReactLynx.snapshotCreatorMap[__snapshot_da39a_test_1] = (uniqId)=>ReactLynx.createSnapshot(uniqId, function() {packages/react/runtime/__test__/snapshotPatch.test.jsx (3)
33-35: Tidy up globals set in testsAttach createSnapshot and DynamicPartType to globalThis only for test scope and restore afterward to avoid cross‑test bleed.
Example:
beforeAll(() => { // ... - globalThis.createSnapshot = createSnapshot; - globalThis.DynamicPartType = DynamicPartType; + const prev = { + createSnapshot: globalThis.createSnapshot, + DynamicPartType: globalThis.DynamicPartType, + }; + globalThis.createSnapshot = createSnapshot; + globalThis.DynamicPartType = DynamicPartType; + vi.stubGlobal('__prevGlobals__', prev); }); afterEach(() => { elementTree.clear(); vi.clearAllMocks(); }); + +afterAll(() => { + const prev = globalThis.__prevGlobals__; + if (prev) { + globalThis.createSnapshot = prev.createSnapshot; + globalThis.DynamicPartType = prev.DynamicPartType; + delete globalThis.__prevGlobals__; + } +})
797-800: No‑op assertionexpect(si.ensureElements()) doesn’t assert anything; prefer explicit non‑throw or remove.
Examples:
- expect(si.ensureElements()); + expect(() => si.ensureElements()).not.toThrow();or
- expect(si.ensureElements());Also applies to: 876-879
1137-1163: entryName global should be restoredGlobal entryName is set but not cleaned up; restore or delete to prevent leakage across tests.
Example:
- globalThis.entryName = 'FOO'; + const prevEntry = globalThis.entryName; + globalThis.entryName = 'FOO'; // … + globalThis.entryName = prevEntry;Also applies to: 1230-1257
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static_snapshot_extract.js (1)
2-15: Lazy registration shape looks correctRegistry wiring and factory body match runtime expectations. One note: factories return void; align runtime type to void for snapshotCreatorMap to reflect usage (see runtime comment).
17eb8ad to
b78f386
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
♻️ Duplicate comments (4)
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_ref.js (1)
27-34: Slot must not be null (regression). Use empty array.
nullwill crash when runtime readsslot.length. Emit[].Apply:
- ], null, undefined, globDynamicComponentEntry, [ + ], [], undefined, globDynamicComponentEntry, [packages/react/runtime/src/lifecycle/patch/snapshotPatchApply.ts (1)
85-93: LGTM! Direct assignment enables HMR updates.The implementation correctly uses direct assignment (
=) instead of nullish-coalescing assignment (??=), ensuring that HMR updates replace previous snapshot creators. This properly addresses the concern raised in previous reviews.packages/react/runtime/src/snapshot.ts (1)
279-288: Verify snapshot creation completed before non-null assertion.The code checks for a creator before invoking it, but Line 288 uses a non-null assertion (
!) onsnapshotManager.values.get(type)without verifying the creator actually populated the map. If the creator fails silently or doesn't register the snapshot, this could throw a confusing error.Consider guarding the assignment:
if (!snapshotManager.values.has(type) && type !== 'div') { if (snapshotCreatorMap[type]) { snapshotCreatorMap[type](type); } else { throw new Error('Snapshot not found: ' + type); } } - this.__snapshot_def = snapshotManager.values.get(type)!; + const snapshot_def = snapshotManager.values.get(type); + if (!snapshot_def && type !== 'div') { + throw new Error(`Snapshot creation failed for type: ${type}`); + } + this.__snapshot_def = snapshot_def!;packages/react/runtime/__test__/snapshotPatch.test.jsx (1)
1463-1467: Inconsistent error message in BackgroundSnapshotInstance test.The test on Line 1464 expects
'Snapshot not found: missing-snapshot'forBackgroundSnapshotInstance, but according topackages/react/runtime/src/backgroundSnapshot.ts:48, it should throw'BackgroundSnapshot not found: missing-snapshot'. Line 1467 correctly expects'Snapshot not found:'forSnapshotInstance.Apply this diff to fix the assertion:
- expect(() => new BackgroundSnapshotInstance('missing-snapshot')).toThrowError( - 'Snapshot not found: missing-snapshot', - ); + expect(() => new BackgroundSnapshotInstance('missing-snapshot')).toThrowError( + 'BackgroundSnapshot not found: missing-snapshot', + );
🧹 Nitpick comments (12)
packages/react/transform/__test__/css/__snapshots__/transform-imports-css-scoped-modules.js (1)
8-18: Lazy snapshot creation pattern implemented correctly.The registry-based approach successfully defers snapshot creation to runtime. All original arguments (factory, updaters, cssId, etc.) are preserved correctly.
Note: The arrow function parameter shadows the constant from line 7. While this works correctly (the runtime will pass the same key value), it adds slight cognitive overhead. Since this appears to be generated code and follows a consistent pattern across the codebase, this is acceptable.
packages/react/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-all.js (2)
11-11: Add PURE to top-level JSX for consistent DCE.Line 11 emits a bare
_jsxwithout/*#__PURE__*/while line 23 includes it. Align both to enable reliable tree‑shaking of unused top-level JSX.Apply at line 11:
-_jsx(__snapshot_2d408_test_1, {}); +/*#__PURE__*/ _jsx(__snapshot_2d408_test_1, {});Based on learnings.
Also applies to: 23-23
4-10: Optional: avoid parameter shadowing in registry factories.The arrow-param name equals the outer const (e.g.,
__snapshot_2d408_test_1), which reads awkwardly. Consideridfor clarity in emitted code.Example:
-ReactLynx.snapshotCreatorMap[__snapshot_2d408_test_1] = (__snapshot_2d408_test_1)=>ReactLynx.createSnapshot(__snapshot_2d408_test_1, function() { +ReactLynx.snapshotCreatorMap[__snapshot_2d408_test_1] = (id)=>ReactLynx.createSnapshot(id, function() {Also applies to: 13-22, 25-31, 38-44
packages/react/transform/__test__/css/__snapshots__/transform-jsx-defaults.js (2)
11-11: Add PURE to top-level JSX for consistent DCE.Line 11 should mirror line 23 and include
/*#__PURE__*/to allow tree‑shaking.-_jsx(__snapshot_da39a_4683e_1, {}); +/*#__PURE__*/ _jsx(__snapshot_da39a_4683e_1, {});Based on learnings.
Also applies to: 23-23
4-10: Optional: rename factory param to avoid shadowing.Use
idinstead of repeating the const name for readability.-ReactLynx.snapshotCreatorMap[__snapshot_da39a_4683e_1] = (__snapshot_da39a_4683e_1)=>ReactLynx.createSnapshot(__snapshot_da39a_4683e_1, function() { +ReactLynx.snapshotCreatorMap[__snapshot_da39a_4683e_1] = (id)=>ReactLynx.createSnapshot(id, function() {Also applies to: 13-22, 25-31, 38-44
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list_with_fragment.js (1)
3-3: Avoid parameter shadowing; use a descriptive name (e.g., uniqId).Shadowing the constant with an identically named parameter harms readability and confuses stack traces. Rename the parameter and its usage.
Example for one site (apply similarly to others):
-ReactLynx.snapshotCreatorMap[__snapshot_da39a_test_3] = (__snapshot_da39a_test_3)=>ReactLynx.createSnapshot(__snapshot_da39a_test_3, function() { +ReactLynx.snapshotCreatorMap[__snapshot_da39a_test_3] = (uniqId)=>ReactLynx.createSnapshot(uniqId, function() {Also applies to: 11-11, 19-19, 32-32, 40-40
packages/react/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-none-lazy-bundle.js (1)
4-4: Rename the snapshot factory parameter to uniqId for clarity.Avoids shadowing and clarifies intent.
Example:
-ReactLynx.snapshotCreatorMap[__snapshot_2d408_test_1] = (__snapshot_2d408_test_1)=>ReactLynx.createSnapshot(__snapshot_2d408_test_1, function() { +ReactLynx.snapshotCreatorMap[__snapshot_2d408_test_1] = (uniqId)=>ReactLynx.createSnapshot(uniqId, function() {Also applies to: 13-13, 25-25, 38-38
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_dynamic_inline_style.js (1)
3-3: Rename the snapshot factory parameter to uniqId.Improves readability; avoids ident shadowing.
-ReactLynx.snapshotCreatorMap[__snapshot_da39a_test_1] = (__snapshot_da39a_test_1)=>ReactLynx.createSnapshot(__snapshot_da39a_test_1, function() { +ReactLynx.snapshotCreatorMap[__snapshot_da39a_test_1] = (uniqId)=>ReactLynx.createSnapshot(uniqId, function() {Also applies to: 13-13, 30-30, 51-51
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/inline_style_literal_unknown_property.js (1)
2-10: Param name shadowing the keyRename the factory parameter to avoid shadowing.
-ReactLynx.snapshotCreatorMap[__snapshot_da39a_test_1] = (__snapshot_da39a_test_1)=>ReactLynx.createSnapshot(__snapshot_da39a_test_1, function() { +ReactLynx.snapshotCreatorMap[__snapshot_da39a_test_1] = (key)=>ReactLynx.createSnapshot(key, function() {packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_list.js (1)
3-11: De-shadow factory params across all registrationsUse a neutral parameter name for all creators.
-ReactLynx.snapshotCreatorMap[__snapshot_da39a_test_3] = (__snapshot_da39a_test_3)=>ReactLynx.createSnapshot(__snapshot_da39a_test_3, function() { +ReactLynx.snapshotCreatorMap[__snapshot_da39a_test_3] = (key)=>ReactLynx.createSnapshot(key, function() { @@ -ReactLynx.snapshotCreatorMap[__snapshot_da39a_test_2] = (__snapshot_da39a_test_2)=>ReactLynx.createSnapshot(__snapshot_da39a_test_2, function(snapshotInstance) { +ReactLynx.snapshotCreatorMap[__snapshot_da39a_test_2] = (key)=>ReactLynx.createSnapshot(key, function(snapshotInstance) { @@ -ReactLynx.snapshotCreatorMap[__snapshot_da39a_test_4] = (__snapshot_da39a_test_4)=>ReactLynx.createSnapshot(__snapshot_da39a_test_4, function() { +ReactLynx.snapshotCreatorMap[__snapshot_da39a_test_4] = (key)=>ReactLynx.createSnapshot(key, function() { @@ -ReactLynx.snapshotCreatorMap[__snapshot_da39a_test_1] = (__snapshot_da39a_test_1)=>ReactLynx.createSnapshot(__snapshot_da39a_test_1, function() { +ReactLynx.snapshotCreatorMap[__snapshot_da39a_test_1] = (key)=>ReactLynx.createSnapshot(key, function() {Consider unifying dynamic-part representation (symbol vs array form) in generator output to reduce surface variance, unless test coverage depends on both forms.
Also applies to: 13-24, 26-33, 34-55
packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_escape_newline_character.js (1)
2-50: Rename factory param; verify updater index alignment
- Parameter
__snapshot_da39a_test_1shadows the const declaration on line 2. Rename for clarity.- Updater targets element index 8; matches returned array (9 elements: el through el8). Index alignment is correct.
-ReactLynx.snapshotCreatorMap[__snapshot_da39a_test_1] = (__snapshot_da39a_test_1)=>ReactLynx.createSnapshot(__snapshot_da39a_test_1, function() { +ReactLynx.snapshotCreatorMap[__snapshot_da39a_test_1] = (key)=>ReactLynx.createSnapshot(key, function() {packages/react/transform/__test__/fixture.spec.js (1)
82-90: Improve factory parameter naming to reduce shadowing (optional refactor)The snapshot factory generator unnecessarily shadows the outer
snapshot_idvariable. Update the template to use a generic parameter name likekeyorsnapshotInstancefor clarity and to align with the runtime type signature(uniqId: string) => string.Location:
packages/react/transform/crates/swc_plugin_snapshot/lib.rs, line 1416Change:
Replace the template pattern from:($snapshot_id) => $runtime_id.createSnapshot($snapshot_id, ...to:
(key) => $runtime_id.createSnapshot(key, ...All snapshot expectations will regenerate automatically. No functional impact; this improves code readability by avoiding variable shadowing and making it explicit that the parameter receives a value (the snapshot ID) rather than relying on outer scope.
Note: swc_plugin_list uses a different codepath and does not generate this pattern.
...plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_dynamic_inline_style.js
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/react/runtime/__test__/snapshotPatch.test.jsx(23 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-10-29T10:28:27.497Z
Learnt from: upupming
PR: lynx-family/lynx-stack#1899
File: packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_dynamic_inline_style.js:20-24
Timestamp: 2025-10-29T10:28:27.497Z
Learning: Files inside packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/ are auto-generated test snapshot files and should not be manually updated. Any issues with the generated code should be addressed in the code generator/transform logic, not in the snapshots themselves.
Applied to files:
packages/react/runtime/__test__/snapshotPatch.test.jsx
🧬 Code graph analysis (1)
packages/react/runtime/__test__/snapshotPatch.test.jsx (3)
packages/react/runtime/src/snapshot.ts (4)
createSnapshot(218-233)snapshotCreatorMap(138-138)SnapshotInstance(268-652)snapshotManager(58-123)packages/react/runtime/src/lifecycle/patch/snapshotPatchApply.ts (1)
snapshotPatchApply(26-108)packages/react/runtime/src/backgroundSnapshot.ts (1)
BackgroundSnapshotInstance(41-375)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: build / Build (Windows)
- GitHub Check: build / Build (Ubuntu)
- GitHub Check: test-rust / Test (Ubuntu)
🔇 Additional comments (2)
packages/react/runtime/__test__/snapshotPatch.test.jsx (2)
33-34: LGTM: Global bindings for lazy snapshot creationExposing
createSnapshotandDynamicPartTypeonglobalThisis appropriate for the test harness to support the new wrapper-based snapshot creator pattern.
1463-1467: LGTM: Error messages now match runtime behaviorThe test assertions correctly expect
'BackgroundSnapshot not found: missing-snapshot'forBackgroundSnapshotInstanceand'Snapshot not found: missing-snapshot'forSnapshotInstance, matching the error messages thrown by the runtime code. The issue flagged in the previous review has been addressed.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Signed-off-by: Yiming Li <yimingli.cs@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (3)
packages/react/runtime/__test__/snapshotPatch.test.jsx (3)
1463-1466: Updated error message matches runtimeAssertion now expects 'BackgroundSnapshot not found: …', consistent with backgroundSnapshot.ts.
726-726: Fix comment typo: "is can be" → "it can be"Apply consistently in all occurrences.
-// We have to use `snapshotCreatorMap[uniqID1] =` so that is can be created after `initGlobalSnapshotPatch` +// We have to use `snapshotCreatorMap[uniqID1] =` so that it can be created after `initGlobalSnapshotPatch`Also update lines 806, 1051, 1139, 1232 similarly.
Also applies to: 806-806, 1051-1051, 1139-1139, 1232-1232
1083-1106: Inline snapshot uses hardcoded ID instead of the function parameterThis snapshot still shows
globalThis.createSnapshot("with-cssId-0", ...)instead of passing the wrapper's parameter (e.g.,uniqID12). Other tests (basic/with-update/with-slot/with-list/with-entryName) correctly use the parameter. This likely reflects a generator inconsistency for the "cssId only" path.Proposed expectation after fixing the generator:
- "with-cssId-0", + uniqID12,Please fix the generator so the uniqID is not inlined for the cssId-only case, then update this inline snapshot. Based on learnings.
🧹 Nitpick comments (4)
packages/react/runtime/__test__/snapshotPatch.test.jsx (4)
33-35: Global hooks set for tests; consider explicit teardownSetting globalThis.createSnapshot and globalThis.DynamicPartType in beforeAll is fine. Add an afterAll to restore/undefine if other suites share the environment, to avoid cross-suite pollution.
afterEach(() => { elementTree.clear(); vi.clearAllMocks(); }); + +afterAll(() => { + // Optional: avoid leaking globals across suites + try { delete (globalThis as any).createSnapshot; } catch {} + try { delete (globalThis as any).DynamicPartType; } catch {} +})
1136-1164: Clean up entryName set in tests to avoid cross-test leakageThese tests set
globalThis.entryName. Add a local cleanup or an afterEach in this describe to delete it.describe('DEV_ONLY_addSnapshot', () => { beforeEach(() => { globalEnvManager.switchToBackground(); initGlobalSnapshotPatch(); }); + + afterEach(() => { + try { delete (globalThis as any).entryName; } catch {} + });Also applies to: 1229-1257
752-780: HMR semantics covered; consider adding an explicit override testYou validate registration via patch and instantiation. Add a small test that registers an initial creator, applies a patch with a different creator for the same id, and asserts the new behavior to prevent regressing to coalescing semantics.
I can draft a minimal test if you want.
Also applies to: 833-859, 995-1025, 1341-1361
782-801: Remove no-op expectations on ensureElements
expect(si.ensureElements());has no matcher and is a no-op. Call the method, then assert on resulting state (which you already do).- const si = new SnapshotInstance(uniqID1); - expect(si.ensureElements()); + const si = new SnapshotInstance(uniqID1); + si.ensureElements();Apply at lines 798 and 877 (basic and with update blocks).
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/react/runtime/__test__/snapshotPatch.test.jsx(23 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-10-29T10:28:27.497Z
Learnt from: upupming
PR: lynx-family/lynx-stack#1899
File: packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_dynamic_inline_style.js:20-24
Timestamp: 2025-10-29T10:28:27.497Z
Learning: Files inside packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/ are auto-generated test snapshot files and should not be manually updated. Any issues with the generated code should be addressed in the code generator/transform logic, not in the snapshots themselves.
Applied to files:
packages/react/runtime/__test__/snapshotPatch.test.jsx
📚 Learning: 2025-09-23T08:54:39.966Z
Learnt from: upupming
PR: lynx-family/lynx-stack#1670
File: packages/webpack/css-extract-webpack-plugin/test/hotCases/hot/hot-update-json/dual-thread/__snapshot__/index.css:6-8
Timestamp: 2025-09-23T08:54:39.966Z
Learning: In the lynx-stack CSS extract webpack plugin tests, many test fixture CSS files intentionally use invalid CSS syntax like `color: 'red';` with quoted values. The snapshots correctly reflect this invalid CSS from the source fixtures. To fix CSS validation issues, the source fixture files should be updated first, then snapshots regenerated, rather than manually editing snapshots.
Applied to files:
packages/react/runtime/__test__/snapshotPatch.test.jsx
🧬 Code graph analysis (1)
packages/react/runtime/__test__/snapshotPatch.test.jsx (3)
packages/react/runtime/src/snapshot.ts (4)
createSnapshot(218-233)snapshotCreatorMap(138-138)SnapshotInstance(268-652)snapshotManager(58-123)packages/react/runtime/src/lifecycle/patch/snapshotPatchApply.ts (1)
snapshotPatchApply(26-108)packages/react/runtime/src/backgroundSnapshot.ts (1)
BackgroundSnapshotInstance(41-375)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: build / Build (Windows)
- GitHub Check: build / Build (Ubuntu)
- GitHub Check: test-rust / Test (Ubuntu)
🔇 Additional comments (2)
packages/react/runtime/__test__/snapshotPatch.test.jsx (2)
17-23: Imports look correct and are all usedThe added imports are necessary for the new lazy-creator tests and are referenced below.
885-911: Slot and list tests reflect the new lazy creator flowGood coverage for slot and list, including isListHolder.
Also applies to: 967-991
| const uniqID1 = 'basic-0'; | ||
| // We have to use `snapshotCreatorMap[uniqID1] =` so that is can be created after `initGlobalSnapshotPatch` | ||
| snapshotCreatorMap[uniqID1] = (uniqID1) => { | ||
| globalThis.createSnapshot( | ||
| uniqID1, | ||
| // The `create` function is stringified and called by `new Function()` | ||
| /* v8 ignore start */ | ||
| () => { | ||
| const pageId = 0; | ||
| const el = __CreateView(pageId); | ||
| const el1 = __CreateText(pageId); | ||
| __AppendElement(el, el1); | ||
| const el2 = __CreateRawText('Hello, ReactLynx x Fast Refresh'); | ||
| __AppendElement(el1, el2); | ||
| return [ | ||
| el, | ||
| el1, | ||
| el2, | ||
| ]; | ||
| }, | ||
| /* v8 ignore stop */ | ||
| null, | ||
| null, | ||
| ); | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
snapshotCreatorMap creator returns void here; align runtime type or return the id
Tests register creators that don't return anything, but runtime typing still suggests (uniqId: string) => string. Either change runtime typing to void (preferred) or return uniqID1 from these lambdas.
If not already updated, consider these diffs outside this file:
-// packages/react/runtime/src/snapshot.ts
-export let snapshotCreatorMap: Record<string, (uniqId: string) => string> = {};
+export let snapshotCreatorMap: Record<string, (uniqId: string) => void> = {};-// packages/react/runtime/src/lifecycle/patch/snapshotPatchApply.ts
- snapshotCreatorMap[uniqID] = evaluate<(uniqId: string) => string>(snapshotCreator);
+ snapshotCreatorMap[uniqID] = evaluate<(uniqId: string) => void>(snapshotCreator);To confirm current state:
🏁 Script executed:
#!/bin/bash
rg -nP -C2 'snapshotCreatorMap\s*:\s*Record<\s*string,\s*\(uniqId:\s*string\)\s*=>\s*\w+\s*>' packages/react/runtime/src
rg -nP -C2 'evaluate<\s*\(uniqId:\s*string\)\s*=>\s*\w+\s*>' packages/react/runtime/src/lifecycle/patch/snapshotPatchApply.tsLength of output: 536
I need to verify where snapshotCreatorMap values are called and whether their return values are used.
I need to find where snapshotCreatorMap functions are actually invoked in the codebase to see if return values are used.
🏁 Script executed:
#!/bin/bash
# Find all places where snapshotCreatorMap functions are called/invoked
rg -nP 'snapshotCreatorMap\s*\[' packages/react/runtime/src -A2 -B2
# Also search for any assignment of the result
rg -nP '=.*snapshotCreatorMap' packages/react/runtime/src -A1 -B1Length of output: 1876
Update type signature for snapshotCreatorMap from string to void return
The review comment is accurate. Call sites in snapshot.ts:283 and backgroundSnapshot.ts:46 invoke the creators but discard return values. The type signature should match the actual behavior.
Changes needed:
-
packages/react/runtime/src/snapshot.ts:138— ChangeRecord<string, (uniqId: string) => string>toRecord<string, (uniqId: string) => void> -
packages/react/runtime/src/snapshot.ts:142— Update Proxy type from(uniqId: string) => stringto(uniqId: string) => void -
packages/react/runtime/src/lifecycle/patch/snapshotPatchApply.ts:92— Changeevaluate<(uniqId: string) => string>toevaluate<(uniqId: string) => void>
🤖 Prompt for AI Agents
In packages/react/runtime/src/snapshot.ts around lines 138 and 142 and in
packages/react/runtime/src/lifecycle/patch/snapshotPatchApply.ts around line 92,
update the creator type signatures from returning string to returning void:
change Record<string, (uniqId: string) => string> to Record<string, (uniqId:
string) => void>, update the Proxy type from (uniqId: string) => string to
(uniqId: string) => void, and change evaluate<(uniqId: string) => string> to
evaluate<(uniqId: string) => void>; this aligns the types with call sites that
invoke creators for side effects and discard return values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We keep this for the compatibility with loading old version lazy bundles, they will still use const snapshot_xxx = createSnapshot(...) directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@upupming, thank you for the clarification! That makes perfect sense. Maintaining backward compatibility with existing lazy bundles that use the direct const snapshot_xxx = createSnapshot(...) pattern is a valid reason to keep the return type as string. The type signature correctly accommodates both the legacy pattern (where the return value is used) and the new pattern (where it may be discarded).
I've noted this for future reference.
✏️ Learnings added
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1899
File: packages/react/runtime/__test__/snapshotPatch.test.jsx:725-749
Timestamp: 2025-11-04T10:15:14.916Z
Learning: In packages/react/runtime/src/snapshot.ts, the snapshotCreatorMap type signature uses `Record<string, (uniqId: string) => string>` (returning string) rather than void for backward compatibility. Old lazy bundles still use the pattern `const snapshot_xxx = createSnapshot(...)` directly, which requires createSnapshot to return a value. The snapshotCreatorMap creators that wrap createSnapshot calls must maintain the same return type to support these legacy bundles.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
🧠 Learnings used
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1899
File: packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_dynamic_inline_style.js:20-24
Timestamp: 2025-10-29T10:28:27.519Z
Learning: Files inside packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/ are auto-generated test snapshot files and should not be manually updated. Any issues with the generated code should be addressed in the code generator/transform logic, not in the snapshots themselves.
Learnt from: Sherry-hue
Repo: lynx-family/lynx-stack PR: 1820
File: packages/web-platform/web-tests/tests/react.spec.ts:834-856
Timestamp: 2025-10-11T06:16:12.517Z
Learning: In packages/web-platform/web-tests/tests/react.spec.ts, the tests `basic-bindmouse` and `basic-mts-bindtouchstart` are NOT duplicates despite having similar test structures. They test different event types: `basic-bindmouse` validates mouse events (mousedown, mouseup, mousemove) with mouse-specific properties (button, buttons, x, y, pageX, pageY, clientX, clientY), while `basic-mts-bindtouchstart` validates touch events (touchstart) with touch arrays (touches, targetTouches, changedTouches). The similar test structure is coincidental and follows testing conventions.
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1305
File: packages/testing-library/testing-environment/src/index.ts:255-258
Timestamp: 2025-08-11T05:57:18.212Z
Learning: In the ReactLynx testing environment (`packages/testing-library/testing-environment/src/index.ts`), the dual assignment pattern `target.console.method = console.method = () => {}` is required for rstest compatibility. This is because rstest provides `console` in an IIFE (Immediately Invoked Function Expression), and both the target and global console need to have these methods defined for proper test execution.
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1670
File: packages/webpack/css-extract-webpack-plugin/test/hotCases/hot/hot-update-json/dual-thread/__snapshot__/index.css:6-8
Timestamp: 2025-09-23T08:54:39.966Z
Learning: In the lynx-stack CSS extract webpack plugin tests, many test fixture CSS files intentionally use invalid CSS syntax like `color: 'red';` with quoted values. The snapshots correctly reflect this invalid CSS from the source fixtures. To fix CSS validation issues, the source fixture files should be updated first, then snapshots regenerated, rather than manually editing snapshots.
Learnt from: gaoachao
Repo: lynx-family/lynx-stack PR: 1771
File: packages/react/transform/tests/__swc_snapshots__/src/swc_plugin_snapshot/mod.rs/basic_component_with_static_sibling.js:2-2
Timestamp: 2025-09-18T04:43:54.426Z
Learning: In packages/react/transform/src/swc_plugin_compat/mod.rs, the `add_pure_comment` function at lines 478-482 is specifically for `wrapWithLynxComponent` calls, not `createSnapshot` calls. The PURE comment injection for `createSnapshot` is handled separately in swc_plugin_snapshot/mod.rs. These are two distinct code paths that should be treated differently.
Learnt from: gaoachao
Repo: lynx-family/lynx-stack PR: 1771
File: packages/react/transform/tests/__swc_snapshots__/src/swc_plugin_snapshot/mod.rs/basic_component_with_static_sibling.js:2-2
Timestamp: 2025-09-18T04:43:54.426Z
Learning: In the lynx-family/lynx-stack repository, the `add_pure_comment` function in packages/react/transform/src/swc_plugin_compat/mod.rs (around lines 478-482) is specifically for `wrapWithLynxComponent` calls, not `createSnapshot` calls. The PURE comment injection for `createSnapshot` is handled separately in swc_plugin_snapshot/mod.rs.
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1562
File: packages/react/transform/src/swc_plugin_snapshot/jsx_helpers.rs:261-283
Timestamp: 2025-08-21T07:21:51.621Z
Learning: In packages/react/transform/src/swc_plugin_snapshot/jsx_helpers.rs, the team prefers to keep the original unreachable! logic for JSXSpreadChild in jsx_is_children_full_dynamic function rather than implementing defensive error handling.
Learnt from: f0rdream
Repo: lynx-family/lynx-stack PR: 1835
File: packages/react/worklet-runtime/src/workletRuntime.ts:52-55
Timestamp: 2025-09-28T08:46:43.177Z
Learning: The legacy worklet path with `_lepusWorkletHash` in `packages/react/worklet-runtime/src/workletRuntime.ts` is preserved for compatibility with MTS (Mini-app Threading Service) that doesn't support Initial Frame Rendering. This path will not be touched in current implementations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/react/transform/crates/swc_plugin_snapshot/lib.rs (1)
1415-1443: Consider renaming the creator function parameter to avoid shadowing.At line 1417, the lambda function parameter is named
$snapshot_id, which shadows the outersnapshot_ididentifier used as the map key. While this is functionally correct (the outer value is the entry UID constant, while the parameter receives the runtime UID when called), the shadowing can be confusing.Consider using a distinct parameter name for clarity:
- r#"$runtime_id.snapshotCreatorMap[$snapshot_id] = ($snapshot_id) => $runtime_id.createSnapshot( - $snapshot_id, + r#"$runtime_id.snapshotCreatorMap[$snapshot_id] = (uniqId) => $runtime_id.createSnapshot( + uniqId,This would make it clearer that the creator function receives a runtime ID that may differ from the entry UID stored in the outer
snapshot_idconstant.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/react/transform/crates/swc_plugin_snapshot/lib.rs(3 hunks)
🧰 Additional context used
🧠 Learnings (6)
📓 Common learnings
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1899
File: packages/react/runtime/__test__/snapshotPatch.test.jsx:725-749
Timestamp: 2025-11-04T10:15:14.916Z
Learning: In packages/react/runtime/src/snapshot.ts, the snapshotCreatorMap type signature uses `Record<string, (uniqId: string) => string>` (returning string) rather than void for backward compatibility. Old lazy bundles still use the pattern `const snapshot_xxx = createSnapshot(...)` directly, which requires createSnapshot to return a value. The snapshotCreatorMap creators that wrap createSnapshot calls must maintain the same return type to support these legacy bundles.
📚 Learning: 2025-10-29T10:28:27.519Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1899
File: packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_dynamic_inline_style.js:20-24
Timestamp: 2025-10-29T10:28:27.519Z
Learning: Files inside packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/ are auto-generated test snapshot files and should not be manually updated. Any issues with the generated code should be addressed in the code generator/transform logic, not in the snapshots themselves.
Applied to files:
packages/react/transform/crates/swc_plugin_snapshot/lib.rs
📚 Learning: 2025-11-04T10:15:14.916Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1899
File: packages/react/runtime/__test__/snapshotPatch.test.jsx:725-749
Timestamp: 2025-11-04T10:15:14.916Z
Learning: In packages/react/runtime/src/snapshot.ts, the snapshotCreatorMap type signature uses `Record<string, (uniqId: string) => string>` (returning string) rather than void for backward compatibility. Old lazy bundles still use the pattern `const snapshot_xxx = createSnapshot(...)` directly, which requires createSnapshot to return a value. The snapshotCreatorMap creators that wrap createSnapshot calls must maintain the same return type to support these legacy bundles.
Applied to files:
packages/react/transform/crates/swc_plugin_snapshot/lib.rs
📚 Learning: 2025-09-18T04:43:54.426Z
Learnt from: gaoachao
Repo: lynx-family/lynx-stack PR: 1771
File: packages/react/transform/tests/__swc_snapshots__/src/swc_plugin_snapshot/mod.rs/basic_component_with_static_sibling.js:2-2
Timestamp: 2025-09-18T04:43:54.426Z
Learning: In packages/react/transform/src/swc_plugin_compat/mod.rs, the `add_pure_comment` function at lines 478-482 is specifically for `wrapWithLynxComponent` calls, not `createSnapshot` calls. The PURE comment injection for `createSnapshot` is handled separately in swc_plugin_snapshot/mod.rs. These are two distinct code paths that should be treated differently.
Applied to files:
packages/react/transform/crates/swc_plugin_snapshot/lib.rs
📚 Learning: 2025-09-18T04:43:54.426Z
Learnt from: gaoachao
Repo: lynx-family/lynx-stack PR: 1771
File: packages/react/transform/tests/__swc_snapshots__/src/swc_plugin_snapshot/mod.rs/basic_component_with_static_sibling.js:2-2
Timestamp: 2025-09-18T04:43:54.426Z
Learning: In the lynx-family/lynx-stack repository, the `add_pure_comment` function in packages/react/transform/src/swc_plugin_compat/mod.rs (around lines 478-482) is specifically for `wrapWithLynxComponent` calls, not `createSnapshot` calls. The PURE comment injection for `createSnapshot` is handled separately in swc_plugin_snapshot/mod.rs.
Applied to files:
packages/react/transform/crates/swc_plugin_snapshot/lib.rs
📚 Learning: 2025-08-21T07:21:51.621Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1562
File: packages/react/transform/src/swc_plugin_snapshot/jsx_helpers.rs:261-283
Timestamp: 2025-08-21T07:21:51.621Z
Learning: In packages/react/transform/src/swc_plugin_snapshot/jsx_helpers.rs, the team prefers to keep the original unreachable! logic for JSXSpreadChild in jsx_is_children_full_dynamic function rather than implementing defensive error handling.
Applied to files:
packages/react/transform/crates/swc_plugin_snapshot/lib.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: build / Build (Windows)
- GitHub Check: build / Build (Ubuntu)
- GitHub Check: test-rust / Test (Ubuntu)
🔇 Additional comments (3)
packages/react/transform/crates/swc_plugin_snapshot/lib.rs (3)
1524-1526: LGTM! Dynamic component CSS ID initialization is correct.The logic properly initializes
css_id_valueto 0 for dynamic components when no explicit@jsxCSSIddirective is present. This ensures dynamic components always have a numeric CSS ID, which aligns with the dynamic component entry naming pattern and the runtime's expectations.
1450-1464: LGTM! Correct ordering of snapshot definitions.The code correctly pushes
entry_snapshot_uid_def(line 1463) beforesnapshot_def(line 1464), ensuring thesnapshot_idconstant is defined before it's used as the map key in the creator registration. This maintains proper JavaScript execution order in the generated code.
1415-1443: No issues found. The review comment is incorrect.
globDynamicComponentEntryis properly defined at runtime through webpack's BannerPlugin injection mechanism. Rather than being undefined, this variable is intentionally left as a bare identifier in thequote!macro because it's injected into the generated bundle by build tooling:
- Webpack injects it as a global variable via BannerPlugin:
'use strict';var globDynamicComponentEntry=globDynamicComponentEntry||'__Card__';'- It's also passed as an IIFE parameter in wrapper code:
(function (globDynamicComponentEntry)- Test environments explicitly set it on the global object:
target.globDynamicComponentEntry = '__Card__'The variable will be in scope when the generated JavaScript code executes, making its use as a bare identifier correct and intentional.
Likely an incorrect or invalid review comment.
Summary by CodeRabbit
Breaking Changes
New Features
Tests / Chores
Checklist