Skip to content

feat(react): shared runtime imports#1968

Merged
Yradex merged 2 commits intolynx-family:mainfrom
Yradex:mts/dev-2
Dec 12, 2025
Merged

feat(react): shared runtime imports#1968
Yradex merged 2 commits intolynx-family:mainfrom
Yradex:mts/dev-2

Conversation

@Yradex
Copy link
Copy Markdown
Collaborator

@Yradex Yradex commented Nov 28, 2025

Summary by CodeRabbit

  • New Features

    • Support for declaring cross-thread shared modules via import attributes (e.g. import with runtime: "shared") so main-thread code can reference imported identifiers directly.
  • Documentation

    • Added docs describing usage and limitations (only directly imported identifiers are treated as shared; shared modules don't auto-promote functions; accessing main-thread-only APIs may error).
  • Tests

    • New tests and snapshots covering named/default/namespace/shared imports and invalid/non-string runtime values.

✏️ Tip: You can customize this high-level summary in your review settings.

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).

@Yradex Yradex requested a review from gaoachao as a code owner November 28, 2025 06:58
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Nov 28, 2025

🦋 Changeset detected

Latest commit: abff45c

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

This PR includes changesets to release 1 package
Name Type
@lynx-js/react Patch

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
Copy Markdown
Contributor

coderabbitai bot commented Nov 28, 2025

📝 Walkthrough

Walkthrough

Detects imports annotated with { runtime: "shared" }, records their imported identifiers during a module pre-scan, skips those identifiers during worklet identifier extraction, validates runtime attribute values (emits errors on invalid values), and adds docs and tests covering the behavior.

Changes

Cohort / File(s) Summary
Documentation
\.changeset/shared-runtime-imports.md
New doc describing { runtime: "shared" } import attribute, usage example, and limitations.
Core transform — identifier extractor
packages/react/transform/crates/swc_plugin_worklet/extract_ident.rs
Add shared_identifiers: Option<FxHashSet<Id>> to ExtractingIdentsCollectorConfig; skip processing identifiers present in the shared set in visit_mut_ident.
Core transform — worklet visitor
packages/react/transform/crates/swc_plugin_worklet/lib.rs
Add shared_identifiers: FxHashSet<Id> field to WorkletVisitor (initialized in constructors); import FxHashSet and HANDLER; pre-scan module imports to populate shared identifiers (Named/Default/Namespace and string-literal keys) when { runtime: "shared" } is present; thread set into extractor config calls; add is_shared_runtime_import, validate_runtime_value, and emit_invalid_runtime_error; emit errors for invalid/non-string runtime values; synthesize shims for public specifiers.
Tests — snapshots
packages/react/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/*.js
Add snapshots exercising shared-runtime imports: named, default, namespace, renamed/shadowed, string-keyed, and Lepus scenario to validate skipping and access patterns.
Tests — runtime validation
packages/react/transform/__test__/fixture.spec.js
Add tests asserting errors are emitted for unsupported or non-string runtime values in import attributes.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Areas needing extra attention:
    • Public API visibility: WorkletVisitor.shared_identifiers exposure and propagation into extractor config.
    • Accurate detection of { runtime: "shared" } across Named, Default, Namespace imports and string-literal keys.
    • Error reporting via HANDLER for invalid/non-string runtime values.
    • Shim/synthetic import generation for public specifiers and interactions with existing transforms.
    • New/updated tests and snapshots matching transform behavior and edge cases (shadowing, namespace imports).

Suggested reviewers

  • gaoachao
  • hzy
  • colinaaa

Poem

🐰 I hop through imports, soft and keen,
I mark the ones that run between,
Shared names I skip in worklet play,
Threads keep them near, yet far away,
A tiny hop — new paths convene.

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 'feat(react): shared runtime imports' clearly and concisely describes the main feature being added—support for shared runtime imports in the React framework. It aligns with the changeset documentation and code modifications across multiple files that implement this feature.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 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 89f3d10 and abff45c.

📒 Files selected for processing (2)
  • packages/react/transform/__test__/fixture.spec.js (1 hunks)
  • packages/react/transform/crates/swc_plugin_worklet/lib.rs (11 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/react/transform/test/fixture.spec.js
🧰 Additional context used
🧠 Learnings (8)
📓 Common learnings
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 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.
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1523
File: vitest.config.ts:5-6
Timestamp: 2025-08-13T11:46:43.737Z
Learning: In the lynx-stack codebase, default imports are consistently used for Node.js built-in modules (e.g., `import os from 'node:os'`, `import fs from 'node:fs'`). The TypeScript configuration supports esModuleInterop and allowSyntheticDefaultImports, making default imports the preferred pattern over namespace imports for Node.js built-ins.
Learnt from: gaoachao
Repo: lynx-family/lynx-stack PR: 1736
File: .changeset/spotty-experts-smoke.md:1-3
Timestamp: 2025-09-12T09:43:04.847Z
Learning: In the lynx-family/lynx-stack repository, private packages (marked with "private": true in package.json) like lynx-js/react-transform don't require meaningful changeset entries even when their public APIs change, since they are not published externally and only affect internal development.
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 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.
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.
📚 Learning: 2025-11-05T03:26:52.546Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1916
File: packages/react/transform/crates/swc_plugin_snapshot/lib.rs:9-9
Timestamp: 2025-11-05T03:26:52.546Z
Learning: In the lynx-stack repository's swc_core v47 upgrade (PR #1916), the import `use swc_core::atoms as swc_atoms;` is required in files that use the `quote!` macro (e.g., packages/react/transform/crates/swc_plugin_snapshot/lib.rs, swc_plugin_list/lib.rs, swc_plugin_worklet/gen_stmt.rs) even though swc_atoms may not appear explicitly in the source code. This is because the quote! macro generates code that internally references swc_atoms. Removing this import causes compiler error: "failed to resolve: use of unresolved module or unlinked crate `swc_atoms`".

Applied to files:

  • packages/react/transform/crates/swc_plugin_worklet/lib.rs
📚 Learning: 2025-09-28T08:46:43.177Z
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.

Applied to files:

  • packages/react/transform/crates/swc_plugin_worklet/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_worklet/lib.rs
📚 Learning: 2025-09-10T11:42:36.855Z
Learnt from: gaoachao
Repo: lynx-family/lynx-stack PR: 1714
File: packages/react/transform/Cargo.toml:19-19
Timestamp: 2025-09-10T11:42:36.855Z
Learning: In packages/react/transform/Cargo.toml, the crate uses serde derive macros (#[derive(Serialize, Deserialize)]) in multiple files including src/esbuild.rs and src/swc_plugin_extract_str/mod.rs, so the "derive" feature is required when migrating to workspace dependencies.

Applied to files:

  • packages/react/transform/crates/swc_plugin_worklet/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_worklet/lib.rs
📚 Learning: 2025-08-11T05:57:18.212Z
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.

Applied to files:

  • packages/react/transform/crates/swc_plugin_worklet/lib.rs
📚 Learning: 2025-08-27T12:42:01.095Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 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_worklet/lib.rs
🧬 Code graph analysis (1)
packages/react/transform/crates/swc_plugin_worklet/lib.rs (1)
packages/react/transform/crates/swc_plugin_worklet/extract_ident.rs (1)
  • new (48-65)
🔇 Additional comments (7)
packages/react/transform/crates/swc_plugin_worklet/lib.rs (7)

11-11: LGTM - Appropriate imports for the new functionality.

The FxHashSet import provides efficient identifier tracking, and HANDLER is the standard mechanism for error emission in SWC plugins.

Also applies to: 16-16


62-62: LGTM - Well-chosen data structure for identifier tracking.

The FxHashSet<Id> field provides O(1) lookup performance for checking whether identifiers should be skipped during worklet extraction.


368-387: LGTM - Comprehensive import pre-scan logic.

The pre-scan correctly handles all import specifier types (named, default, namespace) and properly extracts local binding IDs before the transformation phase. The ordering ensures shared identifiers are available when worklets are processed.


467-512: LGTM - Robust validation addresses previous review feedback.

The validation logic correctly:

  • Restricts runtime values to "shared" only
  • Emits clear error messages for invalid values
  • Handles both identifier and string literal keys for the runtime attribute
  • Returns false for invalid cases to prevent incorrect processing

This directly addresses the past review comment requesting validation for invalid runtime values.


88-91: LGTM - Consistent propagation across all worklet transformation paths.

The shared_identifiers are correctly cloned and passed to ExtractingIdentsCollectorConfig in all five worklet detection paths (class methods, function declarations, arrow expressions, function expressions, and exported functions). While clone() is called for each worklet, FxHashSet cloning is efficient for typical use cases.

Also applies to: 148-151, 195-198, 250-253, 317-320


528-528: LGTM - Proper initialization.

The shared_identifiers field is correctly initialized to an empty set, ready to be populated during the module pre-scan phase.


757-959: LGTM - Comprehensive test coverage.

The test suite thoroughly validates the shared runtime import functionality across:

  • All import specifier types (named, default, namespace)
  • Both identifier and string literal keys for the runtime attribute
  • Shadowing scenarios to ensure correct scoping behavior
  • Both JS and LEPUS transformation targets

The tests are well-structured and provide good coverage of the new feature.


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.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Nov 28, 2025

CodSpeed Performance Report

Merging #1968 will degrade performances by 5.15%

Comparing Yradex:mts/dev-2 (abff45c) with main (f7256d5)

Summary

⚡ 1 improvement
❌ 1 regression
✅ 61 untouched
⏩ 3 skipped1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
transform 1000 view elements 45.6 ms 43.2 ms +5.59%
basic-performance-div-10000 401.4 ms 423.1 ms -5.15%

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@relativeci
Copy link
Copy Markdown

relativeci bot commented Nov 28, 2025

Web Explorer

#6573 Bundle Size — 372.9KiB (0%).

abff45c(current) vs f7256d5 main#6568(baseline)

Bundle metrics  no changes
                 Current
#6573
     Baseline
#6568
No change  Initial JS 146.32KiB 146.32KiB
No change  Initial CSS 32.4KiB 32.4KiB
Change  Cache Invalidation 0% 48.3%
No change  Chunks 8 8
No change  Assets 8 8
No change  Modules 230 230
No change  Duplicate Modules 16 16
No change  Duplicate Code 2.97% 2.97%
No change  Packages 4 4
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#6573
     Baseline
#6568
No change  JS 243.52KiB 243.52KiB
No change  Other 96.98KiB 96.98KiB
No change  CSS 32.4KiB 32.4KiB

Bundle analysis reportBranch Yradex:mts/dev-2Project dashboard


Generated by RelativeCIDocumentationReport issue

Copy link
Copy Markdown
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 (2)
packages/react/transform/crates/swc_plugin_worklet/lib.rs (2)

55-63: Shared-identifiers state wiring looks correct; consider clearing per module as a guard

shared_identifiers: FxHashSet<Id> is correctly added to WorkletVisitor and initialized via FxHashSet::default() in new, so the collector always sees a defined set.

Since visit_mut_module is effectively the per-file entrypoint, you might optionally clear this set at the top of that method to guard against any future reuse of the same visitor instance across multiple Modules:

fn visit_mut_module(&mut self, n: &mut Module) {
-    // First process imports to detect shared-runtime modules
+    // Reset per-module shared identifiers before scanning imports
+    self.shared_identifiers.clear();
+    // First process imports to detect shared-runtime modules

Not required today (the visitor is constructed per module in tests/NAPI), but it makes the lifecycle explicit and future-proof.

Also applies to: 523-532


467-515: is_shared_runtime_import only errors on string values; consider also flagging non-string runtime values

The helper correctly detects both identifier and string-literal keys named runtime and:

  • Treats runtime: "shared" and "runtime": "shared" as shared-runtime imports.
  • Emits a clear error for other string values.

Right now, if someone writes something like:

import { foo } from './shared.js' with { runtime: 123 };
// or
import { foo } from './shared.js' with { runtime: someExpr };

is_shared_runtime_import will silently treat this as a non-shared import and will not emit an error, even though the message you're using ("Invalid runtime value. Only 'shared' is supported.") suggests that any non-"shared" value is invalid.

If you want stricter and more predictable behavior, you could extend the match to also error on non-string expressions for runtime, reusing the same message. Conceptually:

-            PropName::Ident(key) if key.sym == "runtime" => {
-              if let Expr::Lit(Lit::Str(value)) = &*kv.value {
-                if value.value == "shared" {
-                  return true;
-                } else {
-                  HANDLER.with(|handler| {
-                    handler
-                      .struct_span_err(
-                        value.span,
-                        "Invalid runtime value. Only 'shared' is supported.",
-                      )
-                      .emit();
-                  });
-                  return false;
-                }
-              }
-            }
+            PropName::Ident(key) if key.sym == "runtime" => {
+              match &*kv.value {
+                Expr::Lit(Lit::Str(value)) if value.value == "shared" => {
+                  return true;
+                }
+                Expr::Lit(Lit::Str(value)) => {
+                  HANDLER.with(|handler| {
+                    handler
+                      .struct_span_err(
+                        value.span,
+                        "Invalid runtime value. Only 'shared' is supported.",
+                      )
+                      .emit();
+                  });
+                  return false;
+                }
+                other => {
+                  HANDLER.with(|handler| {
+                    handler
+                      .struct_span_err(
+                        other.span(),
+                        "Invalid runtime value. Only 'shared' is supported.",
+                      )
+                      .emit();
+                  });
+                  return false;
+                }
+              }
+            }

and similarly for the PropName::Str case. This keeps the existing error text (so your new JS test still passes) while making the semantics clearer and rejecting obviously invalid runtime attribute shapes instead of silently ignoring them.

📜 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 4d826c0 and 455b8ef.

📒 Files selected for processing (2)
  • packages/react/transform/__test__/fixture.spec.js (1 hunks)
  • packages/react/transform/crates/swc_plugin_worklet/lib.rs (11 hunks)
🧰 Additional context used
🧠 Learnings (12)
📓 Common learnings
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1523
File: vitest.config.ts:5-6
Timestamp: 2025-08-13T11:46:43.737Z
Learning: In the lynx-stack codebase, default imports are consistently used for Node.js built-in modules (e.g., `import os from 'node:os'`, `import fs from 'node:fs'`). The TypeScript configuration supports esModuleInterop and allowSyntheticDefaultImports, making default imports the preferred pattern over namespace imports for Node.js built-ins.
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 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.
Learnt from: gaoachao
Repo: lynx-family/lynx-stack PR: 1736
File: .changeset/spotty-experts-smoke.md:1-3
Timestamp: 2025-09-12T09:43:04.847Z
Learning: In the lynx-family/lynx-stack repository, private packages (marked with "private": true in package.json) like lynx-js/react-transform don't require meaningful changeset entries even when their public APIs change, since they are not published externally and only affect internal development.
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.
📚 Learning: 2025-09-28T08:46:43.177Z
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.

Applied to files:

  • packages/react/transform/__test__/fixture.spec.js
  • packages/react/transform/crates/swc_plugin_worklet/lib.rs
📚 Learning: 2025-08-27T12:42:01.095Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 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/__test__/fixture.spec.js
  • packages/react/transform/crates/swc_plugin_worklet/lib.rs
📚 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/__test__/fixture.spec.js
  • packages/react/transform/crates/swc_plugin_worklet/lib.rs
📚 Learning: 2025-08-21T08:46:54.494Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1370
File: packages/webpack/cache-events-webpack-plugin/src/LynxCacheEventsRuntimeModule.ts:23-27
Timestamp: 2025-08-21T08:46:54.494Z
Learning: In Lynx webpack runtime modules, the team prioritizes performance and simplicity over defensive runtime error handling. They prefer relying on compile-time type safety (TypeScript) rather than adding runtime checks like try-catch blocks or type validation, especially for performance-critical code like cache event setup/cleanup functions.

Applied to files:

  • packages/react/transform/__test__/fixture.spec.js
📚 Learning: 2025-08-11T05:57:18.212Z
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.

Applied to files:

  • packages/react/transform/__test__/fixture.spec.js
  • packages/react/transform/crates/swc_plugin_worklet/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/__test__/fixture.spec.js
  • packages/react/transform/crates/swc_plugin_worklet/lib.rs
📚 Learning: 2025-08-12T16:09:32.413Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 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__/fixture.spec.js
📚 Learning: 2025-08-11T06:00:04.376Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1305
File: packages/react/testing-library/src/plugins/vitest.ts:59-61
Timestamp: 2025-08-11T06:00:04.376Z
Learning: In the lynx-family/lynx-stack repository, the `testingLibraryPlugin` in `packages/react/testing-library/src/plugins/vitest.ts` intentionally uses `process.exit` when jsdom installation fails, maintaining consistency with the previous implementation from `packages/react/testing-library/src/vitest.config.js`. This behavior should not be changed to use `this.error` despite being a Vite plugin best practice.

Applied to files:

  • packages/react/transform/__test__/fixture.spec.js
📚 Learning: 2025-11-05T03:26:52.546Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1916
File: packages/react/transform/crates/swc_plugin_snapshot/lib.rs:9-9
Timestamp: 2025-11-05T03:26:52.546Z
Learning: In the lynx-stack repository's swc_core v47 upgrade (PR #1916), the import `use swc_core::atoms as swc_atoms;` is required in files that use the `quote!` macro (e.g., packages/react/transform/crates/swc_plugin_snapshot/lib.rs, swc_plugin_list/lib.rs, swc_plugin_worklet/gen_stmt.rs) even though swc_atoms may not appear explicitly in the source code. This is because the quote! macro generates code that internally references swc_atoms. Removing this import causes compiler error: "failed to resolve: use of unresolved module or unlinked crate `swc_atoms`".

Applied to files:

  • packages/react/transform/crates/swc_plugin_worklet/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_worklet/lib.rs
📚 Learning: 2025-09-10T11:42:36.855Z
Learnt from: gaoachao
Repo: lynx-family/lynx-stack PR: 1714
File: packages/react/transform/Cargo.toml:19-19
Timestamp: 2025-09-10T11:42:36.855Z
Learning: In packages/react/transform/Cargo.toml, the crate uses serde derive macros (#[derive(Serialize, Deserialize)]) in multiple files including src/esbuild.rs and src/swc_plugin_extract_str/mod.rs, so the "derive" feature is required when migrating to workspace dependencies.

Applied to files:

  • packages/react/transform/crates/swc_plugin_worklet/lib.rs
🧬 Code graph analysis (1)
packages/react/transform/crates/swc_plugin_worklet/lib.rs (3)
packages/react/transform/crates/swc_plugin_worklet/extract_ident.rs (1)
  • new (48-65)
packages/react/transform/crates/swc_plugin_worklet/napi.rs (1)
  • new (104-108)
packages/react/transform/swc-plugin-reactlynx/index.d.ts (1)
  • WorkletVisitorConfig (185-200)
⏰ 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: test-rust / Test (Ubuntu)
🔇 Additional comments (4)
packages/react/transform/crates/swc_plugin_worklet/lib.rs (3)

88-91: Consistent propagation of shared_identifiers into the extractor

All entry points that build ExtractingIdentsCollectorConfig now pass shared_identifiers: Some(self.shared_identifiers.clone()), so class methods, function declarations, arrows, function expressions, and default-exported functions all share the same shared-runtime identifier skip list.

This is exactly what you want for coherent behavior across different worklet shapes; no call site appears to be missing this wiring.

Also applies to: 148-151, 195-198, 250-253, 317-320


367-387: Import pre-scan for shared-runtime identifiers is straightforward and scoped to original module body

The import pre-scan in visit_mut_module correctly:

  • Filters only ImportDecls.
  • Uses is_shared_runtime_import to gate work.
  • Inserts the local side of named/default/namespace specifiers into self.shared_identifiers via to_id().

Iterating over &n.body before n.visit_mut_children_with(self) means only the original source imports contribute; the synthetic imports/vars you insert later are naturally ignored, which is exactly what's needed here.


760-963: Shared-runtime tests cover the key shapes and a tricky shadowing case

The new tests (should_skip_shared_identifiers_js, default/namespace variants, string-key variant, renamed-import-with-shadowing, and LEPUS target) give good coverage:

  • Named, default, and namespace imports with { runtime: "shared" }.
  • Both identifier and string-literal keys in the with-clause.
  • A shadowing scenario where a shared-runtime import alias is re-bound in an inner scope.

That should prevent regressions in how shared_identifiers interacts with scope analysis.

packages/react/transform/__test__/fixture.spec.js (1)

1382-1419: Error-path test for invalid runtime value is precise and well scoped

This test clearly exercises the new HANDLER-based error path for runtime: "invalid" on a worklet module and asserts both:

  • A single error is produced.
  • The error text matches the Rust-side message.

That’s a good regression test for the shared-runtime import validation without over-constraining locations or other fields.

Copy link
Copy Markdown
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 (2)
packages/react/transform/crates/swc_plugin_worklet/lib.rs (2)

88-91: Consider avoiding repeated cloning of shared_identifiers

Passing Some(self.shared_identifiers.clone()) into ExtractingIdentsCollectorConfig at each call site is functionally fine, but it does allocate a fresh set on every worklet extraction. If the number of shared imports grows, you might want to switch the config to hold a borrowed or shared reference (e.g. &FxHashSet<Id> or Arc<FxHashSet<Id>>) to avoid cloning while keeping semantics the same.

Also applies to: 148-151, 195-198, 250-253, 317-320


367-387: Shared-runtime import detection and validation behavior

The module pre-scan plus is_shared_runtime_import correctly:

  • Picks up named/default/namespace specifiers under with { runtime: "shared" } and records their local ids as shared so they’re skipped during capture.
  • Handles both identifier and string-literal keys for "runtime".
  • Emits a diagnostic when runtime is a string literal but not "shared", then treats the import as non-shared.

Two minor follow-ups you could consider:

  • Factor the duplicated “invalid runtime value” branch for ident vs string keys into a small helper to keep future changes to the error message in one place.
  • Optionally log or explicitly ignore cases where runtime exists but isn’t a string literal, so unsupported forms don’t silently behave like ordinary imports.

Neither is blocking, the current behavior is coherent with the tests.

Also applies to: 467-515

📜 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 455b8ef and 343eb78.

📒 Files selected for processing (10)
  • .changeset/shared-runtime-imports.md (1 hunks)
  • packages/react/transform/__test__/fixture.spec.js (1 hunks)
  • packages/react/transform/crates/swc_plugin_worklet/extract_ident.rs (2 hunks)
  • packages/react/transform/crates/swc_plugin_worklet/lib.rs (11 hunks)
  • packages/react/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_handle_renamed_import_shadowing_js.js (1 hunks)
  • packages/react/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_skip_shared_identifiers_default_import_js.js (1 hunks)
  • packages/react/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_skip_shared_identifiers_js.js (1 hunks)
  • packages/react/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_skip_shared_identifiers_lepus.js (1 hunks)
  • packages/react/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_skip_shared_identifiers_namespace_import_js.js (1 hunks)
  • packages/react/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_skip_shared_identifiers_string_key_js.js (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .changeset/shared-runtime-imports.md
🚧 Files skipped from review as they are similar to previous changes (7)
  • packages/react/transform/crates/swc_plugin_worklet/extract_ident.rs
  • packages/react/transform/crates/swc_plugin_worklet/tests/swc_snapshots/lib.rs/should_skip_shared_identifiers_default_import_js.js
  • packages/react/transform/crates/swc_plugin_worklet/tests/swc_snapshots/lib.rs/should_skip_shared_identifiers_string_key_js.js
  • packages/react/transform/test/fixture.spec.js
  • packages/react/transform/crates/swc_plugin_worklet/tests/swc_snapshots/lib.rs/should_skip_shared_identifiers_lepus.js
  • packages/react/transform/crates/swc_plugin_worklet/tests/swc_snapshots/lib.rs/should_handle_renamed_import_shadowing_js.js
  • packages/react/transform/crates/swc_plugin_worklet/tests/swc_snapshots/lib.rs/should_skip_shared_identifiers_namespace_import_js.js
🧰 Additional context used
🧠 Learnings (11)
📓 Common learnings
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 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.
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1523
File: vitest.config.ts:5-6
Timestamp: 2025-08-13T11:46:43.737Z
Learning: In the lynx-stack codebase, default imports are consistently used for Node.js built-in modules (e.g., `import os from 'node:os'`, `import fs from 'node:fs'`). The TypeScript configuration supports esModuleInterop and allowSyntheticDefaultImports, making default imports the preferred pattern over namespace imports for Node.js built-ins.
Learnt from: gaoachao
Repo: lynx-family/lynx-stack PR: 1736
File: .changeset/spotty-experts-smoke.md:1-3
Timestamp: 2025-09-12T09:43:04.847Z
Learning: In the lynx-family/lynx-stack repository, private packages (marked with "private": true in package.json) like lynx-js/react-transform don't require meaningful changeset entries even when their public APIs change, since they are not published externally and only affect internal development.
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 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.
📚 Learning: 2025-11-05T03:26:52.546Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1916
File: packages/react/transform/crates/swc_plugin_snapshot/lib.rs:9-9
Timestamp: 2025-11-05T03:26:52.546Z
Learning: In the lynx-stack repository's swc_core v47 upgrade (PR #1916), the import `use swc_core::atoms as swc_atoms;` is required in files that use the `quote!` macro (e.g., packages/react/transform/crates/swc_plugin_snapshot/lib.rs, swc_plugin_list/lib.rs, swc_plugin_worklet/gen_stmt.rs) even though swc_atoms may not appear explicitly in the source code. This is because the quote! macro generates code that internally references swc_atoms. Removing this import causes compiler error: "failed to resolve: use of unresolved module or unlinked crate `swc_atoms`".

Applied to files:

  • packages/react/transform/crates/swc_plugin_worklet/lib.rs
📚 Learning: 2025-09-28T08:46:43.177Z
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.

Applied to files:

  • packages/react/transform/crates/swc_plugin_worklet/lib.rs
  • packages/react/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_skip_shared_identifiers_js.js
📚 Learning: 2025-09-10T11:42:36.855Z
Learnt from: gaoachao
Repo: lynx-family/lynx-stack PR: 1714
File: packages/react/transform/Cargo.toml:19-19
Timestamp: 2025-09-10T11:42:36.855Z
Learning: In packages/react/transform/Cargo.toml, the crate uses serde derive macros (#[derive(Serialize, Deserialize)]) in multiple files including src/esbuild.rs and src/swc_plugin_extract_str/mod.rs, so the "derive" feature is required when migrating to workspace dependencies.

Applied to files:

  • packages/react/transform/crates/swc_plugin_worklet/lib.rs
📚 Learning: 2025-08-11T05:57:18.212Z
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.

Applied to files:

  • packages/react/transform/crates/swc_plugin_worklet/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_worklet/lib.rs
  • packages/react/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_skip_shared_identifiers_js.js
📚 Learning: 2025-08-27T12:42:01.095Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 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_worklet/lib.rs
  • packages/react/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_skip_shared_identifiers_js.js
📚 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_worklet/tests/__swc_snapshots__/lib.rs/should_skip_shared_identifiers_js.js
📚 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_worklet/tests/__swc_snapshots__/lib.rs/should_skip_shared_identifiers_js.js
📚 Learning: 2025-11-04T10:15:14.965Z
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.965Z
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_worklet/tests/__swc_snapshots__/lib.rs/should_skip_shared_identifiers_js.js
📚 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_worklet/tests/__swc_snapshots__/lib.rs/should_skip_shared_identifiers_js.js
🧬 Code graph analysis (1)
packages/react/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_skip_shared_identifiers_js.js (5)
packages/react/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_handle_renamed_import_shadowing_js.js (1)
  • worklet (6-15)
packages/react/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_skip_shared_identifiers_default_import_js.js (1)
  • worklet (4-12)
packages/react/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_skip_shared_identifiers_lepus.js (2)
  • worklet (6-11)
  • worklet (13-13)
packages/react/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_skip_shared_identifiers_namespace_import_js.js (1)
  • worklet (4-12)
packages/react/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_skip_shared_identifiers_string_key_js.js (1)
  • worklet (4-12)
🔇 Additional comments (3)
packages/react/transform/crates/swc_plugin_worklet/lib.rs (2)

11-16: Shared identifier tracking wiring looks correct

Using a dedicated FxHashSet<Id> on WorkletVisitor and initializing it in new() is a clean way to track shared-runtime bindings across the visitor. The additional imports (FxHashSet, HANDLER, DUMMY_SP) are consistent with the rest of the file and don’t introduce issues.

Also applies to: 55-63, 523-532


760-963: New shared-runtime tests give good coverage

The added tests cover:

  • Named, default, and namespace imports with runtime: "shared".
  • String-literal and identifier keys for "runtime".
  • Shadowing of a shared import by a local binding.
  • Both JS and LEPUS transform targets.

This provides solid regression coverage for the new shared-runtime behavior in the worklet transform.

packages/react/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_skip_shared_identifiers_js.js (1)

1-12: Snapshot matches expected shared-runtime behavior

This snapshot correctly shows only y1 being captured in the worklet object (no sharedRuntime), consistent with the new shared-runtime skipping logic and with the other shared-identifier snapshots. Since files under __swc_snapshots__ are generated, there’s nothing to change here by hand.

@relativeci
Copy link
Copy Markdown

relativeci bot commented Dec 8, 2025

React Example

#6413 Bundle Size — 236.9KiB (0%).

abff45c(current) vs f7256d5 main#6408(baseline)

Bundle metrics  no changes
                 Current
#6413
     Baseline
#6408
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.74% 46.74%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#6413
     Baseline
#6408
No change  IMG 145.76KiB 145.76KiB
No change  Other 91.14KiB 91.14KiB

Bundle analysis reportBranch Yradex:mts/dev-2Project dashboard


Generated by RelativeCIDocumentationReport issue

Copy link
Copy Markdown
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 (1)
packages/react/transform/crates/swc_plugin_worklet/lib.rs (1)

467-537: Consider extracting duplicated error-handling logic.

The PropName::Ident (lines 474-500) and PropName::Str (lines 502-528) branches contain nearly identical logic. Consider extracting a helper to reduce duplication:

+fn check_runtime_value(value: &Expr) -> Option<bool> {
+    if let Expr::Lit(Lit::Str(s)) = value {
+        if s.value == "shared" {
+            return Some(true);
+        }
+        HANDLER.with(|handler| {
+            handler
+                .struct_span_err(s.span, "Invalid runtime value. Only 'shared' is supported.")
+                .emit();
+        });
+        return Some(false);
+    }
+    HANDLER.with(|handler| {
+        handler
+            .struct_span_err(value.span(), "Invalid runtime value. Only 'shared' is supported.")
+            .emit();
+    });
+    Some(false)
+}

 fn is_shared_runtime_import(import_decl: &ImportDecl) -> bool {
   if let Some(with_clause) = &import_decl.with {
     for prop in &with_clause.props {
       if let PropOrSpread::Prop(prop) = prop {
         if let Prop::KeyValue(kv) = &**prop {
-          match &kv.key {
-            PropName::Ident(key) if key.sym == "runtime" => {
-              // ... duplicated logic
-            }
-            PropName::Str(s) if s.value == "runtime" => {
-              // ... duplicated logic
-            }
-            _ => {}
-          }
+          let is_runtime_key = match &kv.key {
+            PropName::Ident(key) => key.sym == "runtime",
+            PropName::Str(s) => s.value == "runtime",
+            _ => false,
+          };
+          if is_runtime_key {
+            if let Some(result) = check_runtime_value(&kv.value) {
+              return result;
+            }
+          }
         }
       }
     }
   }
   false
 }

This is optional given current code works correctly.

📜 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 343eb78 and 89f3d10.

📒 Files selected for processing (2)
  • packages/react/transform/__test__/fixture.spec.js (1 hunks)
  • packages/react/transform/crates/swc_plugin_worklet/lib.rs (11 hunks)
🧰 Additional context used
🧠 Learnings (12)
📓 Common learnings
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 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.
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1523
File: vitest.config.ts:5-6
Timestamp: 2025-08-13T11:46:43.737Z
Learning: In the lynx-stack codebase, default imports are consistently used for Node.js built-in modules (e.g., `import os from 'node:os'`, `import fs from 'node:fs'`). The TypeScript configuration supports esModuleInterop and allowSyntheticDefaultImports, making default imports the preferred pattern over namespace imports for Node.js built-ins.
Learnt from: gaoachao
Repo: lynx-family/lynx-stack PR: 1736
File: .changeset/spotty-experts-smoke.md:1-3
Timestamp: 2025-09-12T09:43:04.847Z
Learning: In the lynx-family/lynx-stack repository, private packages (marked with "private": true in package.json) like lynx-js/react-transform don't require meaningful changeset entries even when their public APIs change, since they are not published externally and only affect internal development.
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1238
File: packages/react/runtime/src/debug/component-stack.ts:70-90
Timestamp: 2025-07-18T04:27:18.291Z
Learning: The component-stack.ts file in packages/react/runtime/src/debug/component-stack.ts is a direct fork from https://github.com/preactjs/preact/blob/main/debug/src/component-stack.js. The team prefers to keep it aligned with the upstream Preact version and may contribute improvements back to Preact in the future.
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 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.
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1305
File: packages/react/testing-library/src/plugins/vitest.ts:4-6
Timestamp: 2025-08-11T05:59:28.530Z
Learning: In the lynx-family/lynx-stack repository, the `packages/react/testing-library` package does not have `vite` as a direct dependency. It relies on `vitest` being available from the monorepo root and accesses Vite types through re-exports from `vitest/node`. Direct imports from `vite` should not be suggested for this package.
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1916
File: packages/react/transform/crates/swc_plugin_snapshot/lib.rs:9-9
Timestamp: 2025-11-05T03:26:52.546Z
Learning: In the lynx-stack repository's swc_core v47 upgrade (PR #1916), the import `use swc_core::atoms as swc_atoms;` is required in files that use the `quote!` macro (e.g., packages/react/transform/crates/swc_plugin_snapshot/lib.rs, swc_plugin_list/lib.rs, swc_plugin_worklet/gen_stmt.rs) even though swc_atoms may not appear explicitly in the source code. This is because the quote! macro generates code that internally references swc_atoms. Removing this import causes compiler error: "failed to resolve: use of unresolved module or unlinked crate `swc_atoms`".
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.
📚 Learning: 2025-08-27T12:42:01.095Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 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/__test__/fixture.spec.js
  • packages/react/transform/crates/swc_plugin_worklet/lib.rs
📚 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/__test__/fixture.spec.js
📚 Learning: 2025-09-28T08:46:43.177Z
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.

Applied to files:

  • packages/react/transform/__test__/fixture.spec.js
  • packages/react/transform/crates/swc_plugin_worklet/lib.rs
📚 Learning: 2025-10-11T06:16:12.517Z
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.

Applied to files:

  • packages/react/transform/__test__/fixture.spec.js
📚 Learning: 2025-09-23T08:54:39.966Z
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.

Applied to files:

  • packages/react/transform/__test__/fixture.spec.js
📚 Learning: 2025-08-21T08:46:54.494Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1370
File: packages/webpack/cache-events-webpack-plugin/src/LynxCacheEventsRuntimeModule.ts:23-27
Timestamp: 2025-08-21T08:46:54.494Z
Learning: In Lynx webpack runtime modules, the team prioritizes performance and simplicity over defensive runtime error handling. They prefer relying on compile-time type safety (TypeScript) rather than adding runtime checks like try-catch blocks or type validation, especially for performance-critical code like cache event setup/cleanup functions.

Applied to files:

  • packages/react/transform/__test__/fixture.spec.js
📚 Learning: 2025-08-11T05:57:18.212Z
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.

Applied to files:

  • packages/react/transform/__test__/fixture.spec.js
  • packages/react/transform/crates/swc_plugin_worklet/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/__test__/fixture.spec.js
  • packages/react/transform/crates/swc_plugin_worklet/lib.rs
📚 Learning: 2025-08-12T16:09:32.413Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 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__/fixture.spec.js
📚 Learning: 2025-11-05T03:26:52.546Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1916
File: packages/react/transform/crates/swc_plugin_snapshot/lib.rs:9-9
Timestamp: 2025-11-05T03:26:52.546Z
Learning: In the lynx-stack repository's swc_core v47 upgrade (PR #1916), the import `use swc_core::atoms as swc_atoms;` is required in files that use the `quote!` macro (e.g., packages/react/transform/crates/swc_plugin_snapshot/lib.rs, swc_plugin_list/lib.rs, swc_plugin_worklet/gen_stmt.rs) even though swc_atoms may not appear explicitly in the source code. This is because the quote! macro generates code that internally references swc_atoms. Removing this import causes compiler error: "failed to resolve: use of unresolved module or unlinked crate `swc_atoms`".

Applied to files:

  • packages/react/transform/crates/swc_plugin_worklet/lib.rs
📚 Learning: 2025-09-10T11:42:36.855Z
Learnt from: gaoachao
Repo: lynx-family/lynx-stack PR: 1714
File: packages/react/transform/Cargo.toml:19-19
Timestamp: 2025-09-10T11:42:36.855Z
Learning: In packages/react/transform/Cargo.toml, the crate uses serde derive macros (#[derive(Serialize, Deserialize)]) in multiple files including src/esbuild.rs and src/swc_plugin_extract_str/mod.rs, so the "derive" feature is required when migrating to workspace dependencies.

Applied to files:

  • packages/react/transform/crates/swc_plugin_worklet/lib.rs
🧬 Code graph analysis (2)
packages/react/transform/__test__/fixture.spec.js (1)
packages/react/transform/rspack-napi/src/index.ts (1)
  • transformReactLynx (161-161)
packages/react/transform/crates/swc_plugin_worklet/lib.rs (2)
packages/react/transform/crates/swc_plugin_worklet/extract_ident.rs (1)
  • new (48-65)
packages/react/transform/crates/swc_plugin_worklet/hash.rs (1)
  • new (8-10)
🔇 Additional comments (5)
packages/react/transform/__test__/fixture.spec.js (1)

1389-1504: LGTM! Good test coverage for error cases.

The three tests comprehensively cover the error scenarios for invalid runtime import attributes:

  1. Invalid runtime value string ("invalid")
  2. Non-string runtime value (123)
  3. String literal key with non-string value ('runtime': 123)

This addresses the past review comment about validating runtime values - invalid values now properly emit an error.

packages/react/transform/crates/swc_plugin_worklet/lib.rs (4)

55-63: LGTM! Appropriate choice of data structure.

FxHashSet<Id> is the correct choice for storing shared identifiers - it provides O(1) lookup and uses SWC's Id type which includes both the symbol and its syntactic context for proper hygiene.


368-387: LGTM! Correct pre-scan approach for shared imports.

The pre-scan correctly:

  1. Iterates over imports before visiting children
  2. Handles all import specifier types (Named, Default, Namespace)
  3. Uses .local.to_id() which captures both the symbol and syntactic context for proper hygiene-aware comparison

88-91: LGTM! Consistent propagation of shared_identifiers.

The shared_identifiers set is correctly cloned and passed to all ExtractingIdentsCollector instantiation sites. The clone is necessary since each collector takes ownership, and the overhead is acceptable given typical import counts.


782-985: LGTM! Comprehensive test coverage.

Excellent test coverage including:

  • All import specifier types (named, default, namespace)
  • String literal key variation ("runtime" vs runtime)
  • Both transform targets (JS, LEPUS)
  • Shadowing scenario to verify hygiene-aware identifier matching

The shadowing test (lines 917-951) is particularly important - it verifies that a locally shadowed variable sr is correctly captured as a closure variable even when the original import sr is marked as shared.

@Yradex Yradex merged commit 9c715ff into lynx-family:main Dec 12, 2025
109 of 119 checks passed
@Yradex Yradex deleted the mts/dev-2 branch December 12, 2025 09:55
colinaaa pushed a commit that referenced this pull request Dec 14, 2025
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @lynx-js/css-extract-webpack-plugin@0.7.0

### Minor Changes

- **BREAKING CHANGE**: Require `@lynx-js/template-webpack-plugin`
0.10.0. ([#1965](#1965))

- Merge all css chunk and generate a `.css.hot-update.json` file for
each bundle.
([#1965](#1965))

## @lynx-js/template-webpack-plugin@0.10.0

### Minor Changes

- Merge all css chunk and generate a `.css.hot-update.json` file for
each bundle.
([#1965](#1965))

## @lynx-js/react@0.115.1

### Patch Changes

- Auto define lynx.loadLazyBundle when using `import(/* relative path
*/)`. ([#1956](#1956))

- feat: support declaring cross-thread shared modules via Import
Attributes, enabling Main Thread Functions to call standard JS functions
directly. ([#1968](#1968))

- Usage: Add `with { runtime: "shared" }` to the `import` statement. For
example:

        ```ts
        import { func } from './utils.js' with { runtime: 'shared' };

        function worklet() {
          'main thread';
          func(); // callable inside a main thread function
        }
        ```

    -   Limitations:
- Only directly imported identifiers are treated as shared; assigning
the import to a new variable will result in the loss of this shared
capability.
- Functions defined within shared modules do not automatically become
Main Thread Functions. Accessing main-thread-only APIs (e.g.,
`MainThreadRef`) will cause errors.

## @lynx-js/rspeedy@0.12.2

### Patch Changes

- Bump Rsbuild v1.6.13 with Rspack v1.6.6.
([#1995](#1995))

-   Updated dependencies \[]:
    -   @lynx-js/web-rsbuild-server-middleware@0.19.1

## @lynx-js/react-rsbuild-plugin@0.12.1

### Patch Changes

- Avoid injecting hot update runtime when dev.hmr or dev.liveReload is
set to false.
([#1980](#1980))

- Updated dependencies
\[[`553ece1`](553ece1),
[`8cdb69d`](8cdb69d),
[`8cdb69d`](8cdb69d)]:
    -   @lynx-js/react-webpack-plugin@0.7.3
    -   @lynx-js/css-extract-webpack-plugin@0.7.0
    -   @lynx-js/template-webpack-plugin@0.10.0
    -   @lynx-js/react-alias-rsbuild-plugin@0.12.1
    -   @lynx-js/use-sync-external-store@1.5.0
    -   @lynx-js/react-refresh-webpack-plugin@0.3.4

## @lynx-js/web-constants@0.19.1

### Patch Changes

-   Updated dependencies \[]:
    -   @lynx-js/web-worker-rpc@0.19.1

## @lynx-js/web-core@0.19.1

### Patch Changes

- fix: support CSP for mts
([#1994](#1994))

- Updated dependencies
\[[`f7256d5`](f7256d5)]:
    -   @lynx-js/web-mainthread-apis@0.19.1
    -   @lynx-js/web-worker-runtime@0.19.1
    -   @lynx-js/web-constants@0.19.1
    -   @lynx-js/web-worker-rpc@0.19.1

## @lynx-js/web-mainthread-apis@0.19.1

### Patch Changes

- fix: fix reload lynx-view when `enableCSSSelector` false may cause css
style lost
([#1982](#1982))

-   Updated dependencies \[]:
    -   @lynx-js/web-constants@0.19.1

## @lynx-js/web-worker-runtime@0.19.1

### Patch Changes

- Updated dependencies
\[[`f7256d5`](f7256d5)]:
    -   @lynx-js/web-mainthread-apis@0.19.1
    -   @lynx-js/web-constants@0.19.1
    -   @lynx-js/web-worker-rpc@0.19.1

## @lynx-js/react-webpack-plugin@0.7.3

### Patch Changes

- Support `@lynx-js/template-webpack-plugin` v0.10.0.
([#1992](#1992))

## create-rspeedy@0.12.2



## @lynx-js/react-alias-rsbuild-plugin@0.12.1



## upgrade-rspeedy@0.12.2



## @lynx-js/web-core-server@0.19.1



## @lynx-js/web-rsbuild-server-middleware@0.19.1



## @lynx-js/web-worker-rpc@0.19.1

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
f0rdream pushed a commit to f0rdream/lynx-stack that referenced this pull request Dec 18, 2025
<!--
  Thank you for submitting a pull request!

We appreciate the time and effort you have invested in making these
changes. Please ensure that you provide enough information to allow
others to review your pull request.

Upon submission, your pull request will be automatically assigned with
reviewers.

If you want to learn more about contributing to this project, please
visit:
https://github.com/lynx-family/lynx-stack/blob/main/CONTRIBUTING.md.
-->

<!-- The AI summary below will be auto-generated - feel free to replace
it with your own. -->

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Support for declaring cross-thread shared modules via import
attributes (e.g. import with runtime: "shared") so main-thread code can
reference imported identifiers directly.

* **Documentation**
* Added docs describing usage and limitations (only directly imported
identifiers are treated as shared; shared modules don't auto-promote
functions; accessing main-thread-only APIs may error).

* **Tests**
* New tests and snapshots covering named/default/namespace/shared
imports and invalid/non-string runtime values.

<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

## Checklist

<!--- Check and mark with an "x" -->

- [x] Tests updated (or not required).
- [ ] Documentation updated (or not required).
- [x] Changeset added, and when a BREAKING CHANGE occurs, it needs to be
clearly marked (or not required).
f0rdream pushed a commit to f0rdream/lynx-stack that referenced this pull request Dec 18, 2025
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @lynx-js/css-extract-webpack-plugin@0.7.0

### Minor Changes

- **BREAKING CHANGE**: Require `@lynx-js/template-webpack-plugin`
0.10.0. ([lynx-family#1965](lynx-family#1965))

- Merge all css chunk and generate a `.css.hot-update.json` file for
each bundle.
([lynx-family#1965](lynx-family#1965))

## @lynx-js/template-webpack-plugin@0.10.0

### Minor Changes

- Merge all css chunk and generate a `.css.hot-update.json` file for
each bundle.
([lynx-family#1965](lynx-family#1965))

## @lynx-js/react@0.115.1

### Patch Changes

- Auto define lynx.loadLazyBundle when using `import(/* relative path
*/)`. ([lynx-family#1956](lynx-family#1956))

- feat: support declaring cross-thread shared modules via Import
Attributes, enabling Main Thread Functions to call standard JS functions
directly. ([lynx-family#1968](lynx-family#1968))

- Usage: Add `with { runtime: "shared" }` to the `import` statement. For
example:

        ```ts
        import { func } from './utils.js' with { runtime: 'shared' };

        function worklet() {
          'main thread';
          func(); // callable inside a main thread function
        }
        ```

    -   Limitations:
- Only directly imported identifiers are treated as shared; assigning
the import to a new variable will result in the loss of this shared
capability.
- Functions defined within shared modules do not automatically become
Main Thread Functions. Accessing main-thread-only APIs (e.g.,
`MainThreadRef`) will cause errors.

## @lynx-js/rspeedy@0.12.2

### Patch Changes

- Bump Rsbuild v1.6.13 with Rspack v1.6.6.
([lynx-family#1995](lynx-family#1995))

-   Updated dependencies \[]:
    -   @lynx-js/web-rsbuild-server-middleware@0.19.1

## @lynx-js/react-rsbuild-plugin@0.12.1

### Patch Changes

- Avoid injecting hot update runtime when dev.hmr or dev.liveReload is
set to false.
([lynx-family#1980](lynx-family#1980))

- Updated dependencies
\[[`553ece1`](lynx-family@553ece1),
[`8cdb69d`](lynx-family@8cdb69d),
[`8cdb69d`](lynx-family@8cdb69d)]:
    -   @lynx-js/react-webpack-plugin@0.7.3
    -   @lynx-js/css-extract-webpack-plugin@0.7.0
    -   @lynx-js/template-webpack-plugin@0.10.0
    -   @lynx-js/react-alias-rsbuild-plugin@0.12.1
    -   @lynx-js/use-sync-external-store@1.5.0
    -   @lynx-js/react-refresh-webpack-plugin@0.3.4

## @lynx-js/web-constants@0.19.1

### Patch Changes

-   Updated dependencies \[]:
    -   @lynx-js/web-worker-rpc@0.19.1

## @lynx-js/web-core@0.19.1

### Patch Changes

- fix: support CSP for mts
([lynx-family#1994](lynx-family#1994))

- Updated dependencies
\[[`f7256d5`](lynx-family@f7256d5)]:
    -   @lynx-js/web-mainthread-apis@0.19.1
    -   @lynx-js/web-worker-runtime@0.19.1
    -   @lynx-js/web-constants@0.19.1
    -   @lynx-js/web-worker-rpc@0.19.1

## @lynx-js/web-mainthread-apis@0.19.1

### Patch Changes

- fix: fix reload lynx-view when `enableCSSSelector` false may cause css
style lost
([lynx-family#1982](lynx-family#1982))

-   Updated dependencies \[]:
    -   @lynx-js/web-constants@0.19.1

## @lynx-js/web-worker-runtime@0.19.1

### Patch Changes

- Updated dependencies
\[[`f7256d5`](lynx-family@f7256d5)]:
    -   @lynx-js/web-mainthread-apis@0.19.1
    -   @lynx-js/web-constants@0.19.1
    -   @lynx-js/web-worker-rpc@0.19.1

## @lynx-js/react-webpack-plugin@0.7.3

### Patch Changes

- Support `@lynx-js/template-webpack-plugin` v0.10.0.
([lynx-family#1992](lynx-family#1992))

## create-rspeedy@0.12.2



## @lynx-js/react-alias-rsbuild-plugin@0.12.1



## upgrade-rspeedy@0.12.2



## @lynx-js/web-core-server@0.19.1



## @lynx-js/web-rsbuild-server-middleware@0.19.1



## @lynx-js/web-worker-rpc@0.19.1

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

3 participants