Skip to content

Conversation

@gaoachao
Copy link
Collaborator

@gaoachao gaoachao commented Sep 12, 2025

A cherry-pick of #1458

Summary by CodeRabbit

  • Tests

    • Updated inline test snapshots to match shifted internal identifiers and adjusted several snapshot test cases; added a lightweight test snapshot helper.
  • Refactor

    • Simplified transformer internals and removed related unused plumbing; tests updated accordingly.
  • Chores

    • Added a placeholder changeset file.

No user-facing features or bug fixes in this release.

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).
  • Changeset added, and when a BREAKING CHANGE occurs, it needs to be clearly marked (or not required).

@gaoachao gaoachao requested review from colinaaa and hzy September 12, 2025 08:57
@changeset-bot
Copy link

changeset-bot bot commented Sep 12, 2025

🦋 Changeset detected

Latest commit: 9d43c03

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 12, 2025

📝 Walkthrough

Walkthrough

Removes the unresolved_mark field/parameter from JSXTransformer and its plumbing, updates transform plugin code and tests to the new constructor arity, adds a global test helper __SNAPSHOT__, refreshes React runtime list test snapshots, and adds a minimal changeset file.

Changes

Cohort / File(s) Summary of changes
Changeset metadata
\.changeset/spotty-experts-smoke.md
Added a minimal changeset skeleton file containing only front-matter delimiters.
Runtime tests: list snapshots
packages/react/runtime/__test__/list.test.jsx
Updated inline snapshots to reflect shifted internal IDs and event-binding tokens; test logic unchanged.
Test globals
packages/react/runtime/__test__/utils/globals.js
Added globalThis.__SNAPSHOT__(snapshot) which returns snapshot.type.
Transform crate top-level
packages/react/transform/src/lib.rs
Updated callsites to drop the unresolved_mark argument when constructing JSXTransformer.
Transform: list plugin tests
packages/react/transform/src/swc_plugin_list/mod.rs
Removed unused Mark import and unresolved_mark usage; updated JSXTransformer::new test invocations to match new arity.
Transform: snapshot plugin core
packages/react/transform/src/swc_plugin_snapshot/mod.rs
Removed unresolved_mark field and the helper that rewrote __SNAPSHOT__ calls; changed JSXTransformer::new(cfg, comments, mode) signature and updated internals/tests accordingly.
Snapshot test outputs / fixtures
packages/react/transform/tests/__swc_snapshots__/*
Deleted/modified several generated snapshot fixtures and tests (removed static extracted snapshot blocks and simplified composed snapshot usages).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • Yradex
  • hzy
  • upupming

Poem

I nibbled the mark till it hopped away,
A tiny global wink now lights the day.
Snapshots hum, IDs settle in line,
Tests refreshed, transformers redesigned.
Rabbit hops off — code and carrots, divine. 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "refactor: impl SNAPSHOT at runtime" succinctly describes the primary change—refactoring SNAPSHOT to be implemented at runtime—which matches the changeset (transformer API removal of unresolved_mark and runtime snapshot handling in tests). It is concise, focused, and relevant for a reviewer scanning PR history.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/impl-snapshot-marcro-at-runtime

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4ba6db9 and 9d43c03.

📒 Files selected for processing (2)
  • packages/react/transform/src/swc_plugin_snapshot/mod.rs (2 hunks)
  • packages/react/transform/tests/__swc_snapshots__/src/swc_plugin_snapshot/mod.rs/basic_list_toplevel.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/react/transform/src/swc_plugin_snapshot/mod.rs
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
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.
📚 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/tests/__swc_snapshots__/src/swc_plugin_snapshot/mod.rs/basic_list_toplevel.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/tests/__swc_snapshots__/src/swc_plugin_snapshot/mod.rs/basic_list_toplevel.js
🧬 Code graph analysis (1)
packages/react/transform/tests/__swc_snapshots__/src/swc_plugin_snapshot/mod.rs/basic_list_toplevel.js (1)
packages/react/transform/tests/__swc_snapshots__/src/swc_plugin_snapshot/mod.rs/basic_list.js (3)
  • __snapshot_da39a_test_1 (30-51)
  • __snapshot_da39a_test_2 (11-22)
  • __snapshot_da39a_test_3 (2-10)
🔇 Additional comments (2)
packages/react/transform/tests/__swc_snapshots__/src/swc_plugin_snapshot/mod.rs/basic_list_toplevel.js (2)

34-37: Inline list-children composition LGTM

The direct inline children array preserves ordering and matches the dynamic part mapping (__DynamicPartListChildren, 0). Also aligns with earlier feedback to remove __SNAPSHOT__ usage in this test.


34-37: Exclude swc_snapshots from TypeScript/ESLint/Jest/Vitest (or configure JSX parsing for snapshots)
Scan found no tsconfig "exclude" entries and no ESLint or Jest/Vitest ignore patterns for swc_snapshots; add the snapshot dir to relevant tsconfig "exclude" (packages that include "test"/"tests" or broad globs), .eslintignore / eslint ignorePatterns or an override using a JSX parser, and test-runner ignore settings (testPathIgnorePatterns / transformIgnorePatterns / modulePathIgnorePatterns).

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gaoachao gaoachao requested review from Yradex and upupming September 12, 2025 08:59
@codecov
Copy link

codecov bot commented Sep 12, 2025

Codecov Report

❌ Patch coverage is 55.55556% with 4 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
.../swc_plugin_snapshot/mod.rs/basic_list_toplevel.js 0.00% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

@relativeci
Copy link

relativeci bot commented Sep 12, 2025

Web Explorer

#5256 Bundle Size — 364.83KiB (-0.09%).

9d43c03(current) vs 75693e4 main#5246(baseline)

Bundle metrics  Change 3 changes Improvement 1 improvement
                 Current
#5256
     Baseline
#5246
Improvement  Initial JS 145.41KiB(-0.16%) 145.65KiB
No change  Initial CSS 31.89KiB 31.89KiB
Change  Cache Invalidation 56.24% 16.33%
No change  Chunks 8 8
No change  Assets 8 8
Change  Modules 219(+0.92%) 217
No change  Duplicate Modules 16 16
No change  Duplicate Code 3.37% 3.37%
No change  Packages 4 4
No change  Duplicate Packages 0 0
Bundle size by type  Change 1 change Improvement 1 improvement
                 Current
#5256
     Baseline
#5246
Improvement  JS 238.92KiB (-0.14%) 239.25KiB
No change  Other 94.02KiB 94.02KiB
No change  CSS 31.89KiB 31.89KiB

Bundle analysis reportBranch refactor/impl-snapshot-marcro-at...Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link

relativeci bot commented Sep 12, 2025

React Example

#5263 Bundle Size — 237.52KiB (0%).

9d43c03(current) vs 75693e4 main#5253(baseline)

Bundle metrics  no changes
                 Current
#5263
     Baseline
#5253
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
No change  Cache Invalidation 0% 0%
No change  Chunks 0 0
No change  Assets 4 4
No change  Modules 162 162
No change  Duplicate Modules 65 65
No change  Duplicate Code 46.71% 46.71%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#5263
     Baseline
#5253
No change  IMG 145.76KiB 145.76KiB
No change  Other 91.76KiB 91.76KiB

Bundle analysis reportBranch refactor/impl-snapshot-marcro-at...Project dashboard


Generated by RelativeCIDocumentationReport issue

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

🧹 Nitpick comments (2)
packages/react/runtime/__test__/utils/globals.js (1)

136-139: Guard against clobbering and handle undefined input.

Avoid overwriting an existing __SNAPSHOT__ (some environments may pre-inject it) and tolerate falsy snapshot.

-  globalThis.__SNAPSHOT__ = (snapshot) => {
-    return snapshot.type;
-  };
+  if (!globalThis.__SNAPSHOT__) {
+    globalThis.__SNAPSHOT__ = (snapshot) => snapshot?.type;
+  }
packages/react/runtime/__test__/list.test.jsx (1)

236-257: Inline snapshots assert unstable IDs/tokens; prefer stable expectations.

Most diffs are ID/token churn (e.g., list IDs -6/-5/-8 and event handler tokens). These are brittle. Recommend asserting structure and key fields while ignoring generated IDs.

Example refactor (one representative block), replacing a long inline snapshot with a shape check:

-    expect(listRef).toMatchInlineSnapshot(`
-      <list
-        id="list"
-        update-list-info={
-          [
-            {
-              "insertAction": [
-                {
-                  "item-key": "key-0",
-                  "position": 0,
-                  "type": "__Card__:__snapshot_a94a8_test_21",
-                },
-                ...
-              ],
-              "removeAction": [],
-              "updateAction": [],
-            },
-          ]
-        }
-      >
-        <list-item item-key="key-4"> ... </list-item>
-        <list-item item-key="key-5"> ... </list-item>
-        <list-item item-key="key-2"> ... </list-item>
-        <list-item item-key="key-3"> ... </list-item>
-      </list>
-    `);
+    expect(listRef).toMatchObject({
+      type: 'list',
+      props: {
+        id: 'list',
+        'update-list-info': expect.arrayContaining([
+          expect.objectContaining({
+            insertAction: expect.arrayContaining([
+              expect.objectContaining({ position: 0, type: expect.stringMatching(/__snapshot_/) }),
+            ]),
+          }),
+        ]),
+      },
+      children: expect.arrayContaining([
+        expect.objectContaining({ type: 'list-item', props: expect.objectContaining({ 'item-key': 'key-4' }) }),
+        expect.objectContaining({ type: 'list-item', props: expect.objectContaining({ 'item-key': 'key-5' }) }),
+      ]),
+    });

If you want, I can batch-generate diffs to replace the most brittle snapshots with pattern-based assertions.

Also applies to: 272-299, 307-322, 355-378, 569-631, 1562-1583, 3666-3721

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 45e3201 and df3c8fd.

📒 Files selected for processing (6)
  • .changeset/spotty-experts-smoke.md (1 hunks)
  • packages/react/runtime/__test__/list.test.jsx (20 hunks)
  • packages/react/runtime/__test__/utils/globals.js (1 hunks)
  • packages/react/transform/src/lib.rs (0 hunks)
  • packages/react/transform/src/swc_plugin_list/mod.rs (1 hunks)
  • packages/react/transform/src/swc_plugin_snapshot/mod.rs (1 hunks)
💤 Files with no reviewable changes (1)
  • packages/react/transform/src/lib.rs
🧰 Additional context used
📓 Path-based instructions (1)
.changeset/*.md

📄 CodeRabbit inference engine (AGENTS.md)

For contributions, always generate a changeset and commit the resulting markdown file(s)

Files:

  • .changeset/spotty-experts-smoke.md
🧠 Learnings (4)
📓 Common learnings
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.
📚 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/runtime/__test__/utils/globals.js
📚 Learning: 2025-08-11T05:57:18.212Z
Learnt from: upupming
PR: lynx-family/lynx-stack#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.

Applied to files:

  • packages/react/runtime/__test__/utils/globals.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/src/swc_plugin_snapshot/mod.rs
  • packages/react/transform/src/swc_plugin_list/mod.rs
🧬 Code graph analysis (1)
packages/react/transform/src/swc_plugin_snapshot/mod.rs (3)
packages/react/transform/src/swc_plugin_compat/mod.rs (1)
  • new (410-422)
packages/react/transform/src/swc_plugin_compat_post/mod.rs (1)
  • new (57-62)
packages/react/transform/src/swc_plugin_inject/mod.rs (1)
  • new (106-114)
⏰ 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/transform/src/swc_plugin_list/mod.rs (1)

185-185: Approve import; confirm no remaining 4‑arg JSXTransformer::new calls

SingleThreadedComments is used in tests to instantiate JSXTransformer::<&SingleThreadedComments>::new(...); import is correct. Ripgrep produced no output — re-run one of the checks below and attach results:

rg -n --type=rust -C2 'JSXTransformer::new\('
rg -nP --type=rust 'JSXTransformer::new\s*\((?:[^()]*,){3}'
packages/react/transform/src/swc_plugin_snapshot/mod.rs (1)

1028-1049: Public API change — constructor now (cfg, comments, mode); update callers, docs, and release notes.

  • Ensure every caller uses the new 3‑arg signature — notable call sites: packages/react/transform/src/lib.rs:481 and many visit_mut_pass(JSXTransformer::new(...)) occurrences in packages/react/transform/src/swc_plugin_snapshot/mod.rs; run: rg -nP --type=rust '\bJSXTransformer::new\s*(' packages/react/transform -S.
  • Add a changeset and bump semver (minor/major as appropriate for a public API change).
  • Update README/API docs to document the new signature (cfg, comments, mode).

@codspeed-hq
Copy link

codspeed-hq bot commented Sep 12, 2025

CodSpeed Performance Report

Merging #1736 will not alter performance

Comparing refactor/impl-snapshot-marcro-at-runtime (9d43c03) with main (93d707b)

🎉 Hooray! codspeed-cpp just leveled up to 1.2.0!

A heads-up, this is a breaking change and it might affect your current performance baseline a bit. But here's the exciting part - it's packed with new, cool features and promises improved result stability 🥳!
Curious about what's new? Visit our releases page to delve into all the awesome details about this new version.

Summary

✅ 56 untouched

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 (5)
packages/react/runtime/__test__/utils/globals.js (1)

136-139: Harden SNAPSHOT helper (optional).

Guard against unexpected inputs and avoid accidental reassignment by defining a non-enumerable property. Keeps tests resilient while remaining overridable if needed.

-  globalThis.__SNAPSHOT__ = (snapshot) => {
-    return snapshot.type;
-  };
+  Object.defineProperty(globalThis, '__SNAPSHOT__', {
+    value: (snapshot) => snapshot?.type ?? snapshot,
+    configurable: true,
+  });
packages/react/runtime/__test__/list.test.jsx (1)

525-631: General note: consider stabilizing brittle snapshot fields (optional).

If these IDs continue to churn due to internal ordering, consider asserting structure with expect.objectContaining/arrayContaining or targeted fields to reduce maintenance overhead. Keep exact IDs where they’re semantically significant.

Also applies to: 1062-1097, 1489-1538, 1665-1719, 1748-1855, 1864-1942, 2206-2282, 2359-2463, 2541-2710, 2757-2792, 2834-2854, 2910-2956, 2999-3033, 3055-3088, 3151-3187, 3331-3387, 3456-3501, 3511-3583, 3603-3611, 3733-3767, 3784-3911

packages/react/transform/src/swc_plugin_list/mod.rs (3)

97-108: Use a hygienic private ident for children to avoid name capture.

Ident::from("__c") can collide with user code. Prefer a fresh, hygienic ident.

-      let children_ident = Ident::from("__c");
+      let children_ident = private_ident!("c");

167-179: Skip adding the runtime import if it already exists.

If a file already imports '@lynx-js/react/runtime-components', this will add a duplicate import. Guard the insertion.

   fn visit_mut_module_items(&mut self, n: &mut Vec<ModuleItem>) {
-    let mut new_items: Vec<ModuleItem> = vec![];
+    let has_runtime_import = n.iter().any(|item| {
+      matches!(
+        item,
+        ModuleItem::ModuleDecl(ModuleDecl::Import(ImportDecl { src, .. }))
+          if &*src.value == "@lynx-js/react/runtime-components"
+      )
+    });
+    let mut new_items: Vec<ModuleItem> = vec![];
     for item in n.iter_mut() {
       item.visit_mut_with(self);
       new_items.push(item.take());
     }
 
-    if let Some(module_item) = &self.runtime_components_module_item {
-      new_items.insert(0, module_item.clone());
+    if let Some(module_item) = &self.runtime_components_module_item && !has_runtime_import {
+      new_items.insert(0, module_item.clone());
     }
 
     *n = new_items;
   }

64-74: Align the comment with the actual renderListItem signature.

The code generates ($children) => ..., not (spread, children) => .... Update the comment to prevent confusion.

-  //   renderListItem={(spread, children) => <list-item ... {...spread}>{children}</list-item>}
+  //   renderListItem={(children) => <list-item ...>{children}</list-item>}
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 45e3201 and 4ba6db9.

📒 Files selected for processing (9)
  • .changeset/spotty-experts-smoke.md (1 hunks)
  • packages/react/runtime/__test__/list.test.jsx (20 hunks)
  • packages/react/runtime/__test__/utils/globals.js (1 hunks)
  • packages/react/transform/src/lib.rs (0 hunks)
  • packages/react/transform/src/swc_plugin_list/mod.rs (1 hunks)
  • packages/react/transform/src/swc_plugin_snapshot/mod.rs (1 hunks)
  • packages/react/transform/tests/__swc_snapshots__/src/swc_plugin_snapshot/mod.rs/basic_full_static_snapshot_extract.js (0 hunks)
  • packages/react/transform/tests/__swc_snapshots__/src/swc_plugin_snapshot/mod.rs/basic_full_static_snapshot_extract_it.js (0 hunks)
  • packages/react/transform/tests/__swc_snapshots__/src/swc_plugin_snapshot/mod.rs/basic_list_toplevel.js (2 hunks)
💤 Files with no reviewable changes (3)
  • packages/react/transform/tests/swc_snapshots/src/swc_plugin_snapshot/mod.rs/basic_full_static_snapshot_extract_it.js
  • packages/react/transform/src/lib.rs
  • packages/react/transform/tests/swc_snapshots/src/swc_plugin_snapshot/mod.rs/basic_full_static_snapshot_extract.js
🧰 Additional context used
📓 Path-based instructions (1)
.changeset/*.md

📄 CodeRabbit inference engine (AGENTS.md)

For contributions, always generate a changeset and commit the resulting markdown file(s)

Files:

  • .changeset/spotty-experts-smoke.md
🧠 Learnings (3)
📚 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/runtime/__test__/utils/globals.js
📚 Learning: 2025-07-22T09:26:16.722Z
Learnt from: colinaaa
PR: lynx-family/lynx-stack#1330
File: .changeset/olive-animals-attend.md:1-3
Timestamp: 2025-07-22T09:26:16.722Z
Learning: In the lynx-family/lynx-stack repository, CI checks require changesets when files matching the pattern "src/**" are modified (as configured in .changeset/config.json). For internal changes that don't need meaningful changesets, an empty changeset file is used to satisfy the CI requirement while not generating any release notes.

Applied to files:

  • .changeset/spotty-experts-smoke.md
📚 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/src/swc_plugin_snapshot/mod.rs
  • packages/react/transform/src/swc_plugin_list/mod.rs
🧬 Code graph analysis (2)
packages/react/transform/src/swc_plugin_snapshot/mod.rs (3)
packages/react/transform/src/swc_plugin_list/mod.rs (1)
  • new (28-34)
packages/react/transform/src/swc_plugin_compat_post/mod.rs (1)
  • new (57-62)
packages/react/transform/src/swc_plugin_inject/mod.rs (1)
  • new (106-114)
packages/react/transform/tests/__swc_snapshots__/src/swc_plugin_snapshot/mod.rs/basic_list_toplevel.js (1)
packages/react/transform/tests/__swc_snapshots__/src/swc_plugin_snapshot/mod.rs/basic_list.js (4)
  • __snapshot_da39a_test_1 (30-51)
  • __snapshot_da39a_test_2 (11-22)
  • __snapshot_da39a_test_3 (2-10)
  • __snapshot_da39a_test_4 (23-29)
⏰ 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 (Windows)
  • GitHub Check: build / Build (Ubuntu)
🔇 Additional comments (12)
.changeset/spotty-experts-smoke.md (1)

1-3: Empty changeset acknowledged and OK for CI.

Per prior repo practice, an empty front matter changeset is acceptable to satisfy CI without generating release notes when touching packages under src/. No action needed.

packages/react/runtime/__test__/utils/globals.js (1)

86-143: Global test shims look consistent.

The new SNAPSHOT aligns with tests that wrap JSX in SNAPSHOT(...). No other behavior changes introduced here.

packages/react/transform/tests/__swc_snapshots__/src/swc_plugin_snapshot/mod.rs/basic_list_toplevel.js (1)

34-37: Snapshot fixture updates are consistent with runtime SNAPSHOT usage.

Wrapping snapshot JSX with SNAPSHOT(...) matches the refactor removing transformer-time rewrites. Looks good.

Also applies to: 48-48

packages/react/runtime/__test__/list.test.jsx (5)

236-257: Pending updates ID reindexing acknowledged.

The negative list IDs in __pendingListUpdates.values were re-numbered; expectations updated accordingly. No functional change detected.

Also applies to: 272-299, 307-322, 355-377


575-576: Event bind IDs re-indexed.

Inline snapshot updates for "bindEvent:tap" IDs are consistent with the new allocation order.

Also applies to: 590-591, 605-606, 620-621


2036-2076: “list bug” expectations updated to new list IDs.

The -5 key and associated actions reflect the new numbering; logic remains the same.

Also applies to: 2083-2117, 2125-2148


3568-3578: Lifecycle handler IDs shifted as expected.

onComponentAtIndex/onRecycleComponent handlerName IDs updated; behavior unchanged.


3666-3686: Nested list: multiple list ID renumberings OK.

Snapshot assertions for parent/child attached lists reflect the new stable order.

Also applies to: 3687-3697, 3699-3709, 3711-3721, 3731-3741, 3743-3753, 3755-3765

packages/react/transform/src/swc_plugin_snapshot/mod.rs (3)

1516-1550: Import injection still guarded and correct.

The runtime import insertion remains intact post-refactor. No issues spotted.


1568-1711: Tests align with the new API and runtime behavior.

Resolver/react passes remain unchanged; JSXTransformer tests updated appropriately.

Also applies to: 1713-1782, 1784-1830, 1832-1876, 1878-1935, 1937-2002, 2004-2033, 2035-2110, 2112-2161, 2163-2207, 2209-2255, 2257-2315, 2317-2355, 2357-2410, 2412-2463, 2465-2515, 2517-2566, 2568-2642


1028-1050: Constructor signature change looks correct; all call sites updated.

Search of packages/react/transform/src found 20 JSXTransformer::new call sites — all use 3 arguments; no lingering 4-arg usages. SNAPSHOT occurs only in packages/react/transform/src/swc_plugin_snapshot/mod.rs; visit_mut_expr is still used in several plugins (expected).

packages/react/transform/src/swc_plugin_list/mod.rs (1)

185-185: Import update LGTM.

Switching tests to SingleThreadedComments aligns with the new JSXTransformer::<&SingleThreadedComments>::new(_, None, TransformMode) API.

colinaaa
colinaaa previously approved these changes Sep 16, 2025
@gaoachao
Copy link
Collaborator Author

gaoachao commented Sep 16, 2025

@hzy @colinaaa PTLA~

@gaoachao gaoachao merged commit 1e920a1 into main Sep 17, 2025
148 of 159 checks passed
@gaoachao gaoachao deleted the refactor/impl-snapshot-marcro-at-runtime branch September 17, 2025 09:35
@coderabbitai coderabbitai bot mentioned this pull request Oct 11, 2025
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants