Skip to content

feat: expose LynxTemplatePlugin to rsbuild API#2051

Merged
colinaaa merged 3 commits intomainfrom
feat/expose-LynxTemplatePlugin
Dec 29, 2025
Merged

feat: expose LynxTemplatePlugin to rsbuild API#2051
colinaaa merged 3 commits intomainfrom
feat/expose-LynxTemplatePlugin

Conversation

@upupming
Copy link
Copy Markdown
Collaborator

@upupming upupming commented Dec 24, 2025

Summary by CodeRabbit

  • New Features

    • Plugin developers can access LynxTemplatePlugin through the rsbuild plugin API and obtain its template hooks.
    • New public type exports for plugin development: LynxTemplatePlugin and TemplateHooks.
  • Tests

    • Added test coverage verifying LynxTemplatePlugin exposure and integration.
  • Documentation

    • Updated usage examples to reflect the new hook access method.
  • Chores

    • Added a changeset entry for a patch release.

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

resolve: #2044

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

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Dec 24, 2025

🦋 Changeset detected

Latest commit: b486a4f

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

This PR includes changesets to release 2 packages
Name Type
@lynx-js/react-rsbuild-plugin Patch
@lynx-js/react-alias-rsbuild-plugin 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 Dec 24, 2025

📝 Walkthrough

Walkthrough

This change exposes the LynxTemplatePlugin via rsbuild under Symbol.for('LynxTemplatePlugin'), adds type re-exports (LynxTemplatePlugin, TemplateHooks) and API doc entries, implements the runtime api.expose in the React rspeedy plugin, and adds a test validating exposure and template hook usage.

Changes

Cohort / File(s) Summary
Changeset doc
\.changeset/thick-ideas-drum.md
Adds a patch changeset entry for @lynx-js/react-rsbuild-plugin.
Type exports & API report
packages/rspeedy/plugin-react/src/index.ts, packages/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
Adds type-only exports LynxTemplatePlugin and TemplateHooks; updates API report to include LynxTemplatePlugin interface and import adjustments.
Plugin runtime exposure
packages/rspeedy/plugin-react/src/pluginReactLynx.ts
Exposes LynxTemplatePlugin via api.expose(Symbol.for('LynxTemplatePlugin'), { LynxTemplatePlugin }) after existing exposures.
Tests
packages/rspeedy/plugin-react/test/expose.test.ts
New test exercising api.useExposed(Symbol.for('LynxTemplatePlugin')), tapping template hooks and asserting build outputs.
Docs/example update
packages/webpack/template-webpack-plugin/src/LynxTemplatePlugin.ts
Example adjusted to call getLynxTemplatePluginHooks(...) (no runtime changes).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Possibly related PRs

Suggested reviewers

  • colinaaa

Poem

🐰 I hopped into code with nimble feet,
I hid a symbol where the hooks may meet.
I whispered types and exposed a key,
Before encode — come play with me.
Tests nibble carrots — build looks sweet.

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: exposing LynxTemplatePlugin to the rsbuild API, which is the primary objective across all modified files.
Linked Issues check ✅ Passed The PR successfully implements the requirement from issue #2044 by exposing LynxTemplatePlugin via rsbuild API using Symbol.for('LynxTemplatePlugin') and providing type exports for consumers to access TemplateHooks.
Out of Scope Changes check ✅ Passed All changes are directly aligned with exposing LynxTemplatePlugin: type exports, API registration, test coverage, and documentation updates. No unrelated modifications detected.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/expose-LynxTemplatePlugin

📜 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 5d906e7 and b486a4f.

📒 Files selected for processing (6)
  • .changeset/thick-ideas-drum.md
  • packages/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
  • packages/rspeedy/plugin-react/src/index.ts
  • packages/rspeedy/plugin-react/src/pluginReactLynx.ts
  • packages/rspeedy/plugin-react/test/expose.test.ts
  • packages/webpack/template-webpack-plugin/src/LynxTemplatePlugin.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/webpack/template-webpack-plugin/src/LynxTemplatePlugin.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • packages/rspeedy/plugin-react/test/expose.test.ts
  • .changeset/thick-ideas-drum.md
  • packages/rspeedy/plugin-react/src/pluginReactLynx.ts
  • packages/rspeedy/plugin-react/src/index.ts
🧰 Additional context used
🧠 Learnings (14)
📓 Common learnings
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: 1612
File: packages/rspeedy/create-rspeedy/template-react-vitest-rltl-ts/src/tsconfig.json:3-13
Timestamp: 2025-08-27T08:10:09.932Z
Learning: In the lynx-family/lynx-stack repository, Rspeedy templates use `lynx-js/rspeedy/client` types via `rspeedy-env.d.ts` instead of `vite/client` types. Rspeedy provides its own client-side environment type definitions and doesn't require direct Vite type references.
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-26T05:10:01.595Z
Learning: Applies to packages/rspeedy/plugin-*/**/*.{ts,tsx,js} : Configure build plugins using the plugin architecture in packages/rspeedy/plugin-*/
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1453
File: vitest.config.ts:49-61
Timestamp: 2025-08-06T13:28:57.182Z
Learning: In the lynx-family/lynx-stack repository, the file `packages/rspeedy/create-rspeedy/template-react-vitest-rltl-js/vitest.config.js` is a template file for scaffolding new Rspeedy projects, not a test configuration that should be included in the main vitest projects array.
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: CR
Repo: lynx-family/lynx-stack PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-26T05:10:01.595Z
Learning: Applies to packages/react/**/*.{ts,tsx} : Use JSX syntax and ReactLynx components in React component files within packages/react/
📚 Learning: 2025-09-12T09:43:04.847Z
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.

Applied to files:

  • packages/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
📚 Learning: 2025-12-26T05:10:01.595Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-26T05:10:01.595Z
Learning: Applies to packages/react/components/**/*.{ts,tsx} : Optimize component library in packages/react/components/ using ReactLynx syntax

Applied to files:

  • packages/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
📚 Learning: 2025-12-26T05:10:01.595Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-26T05:10:01.595Z
Learning: Applies to packages/react/**/*.{ts,tsx} : Use JSX syntax and ReactLynx components in React component files within packages/react/

Applied to files:

  • packages/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
📚 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/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
📚 Learning: 2025-12-26T05:10:01.595Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-26T05:10:01.595Z
Learning: Applies to packages/rspeedy/plugin-*/**/*.{ts,tsx,js} : Configure build plugins using the plugin architecture in packages/rspeedy/plugin-*/

Applied to files:

  • packages/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
📚 Learning: 2025-08-27T08:10:09.932Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1612
File: packages/rspeedy/create-rspeedy/template-react-vitest-rltl-ts/src/tsconfig.json:3-13
Timestamp: 2025-08-27T08:10:09.932Z
Learning: In the lynx-family/lynx-stack repository, Rspeedy templates use `lynx-js/rspeedy/client` types via `rspeedy-env.d.ts` instead of `vite/client` types. Rspeedy provides its own client-side environment type definitions and doesn't require direct Vite type references.

Applied to files:

  • packages/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
📚 Learning: 2025-08-19T11:25:36.127Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1558
File: .changeset/solid-squids-fall.md:2-2
Timestamp: 2025-08-19T11:25:36.127Z
Learning: In the lynx-family/lynx-stack repository, changesets should use the exact package name from package.json#name, not generic or unscoped names. Each package has its own specific scoped name (e.g., "lynx-js/react-transform" for packages/react/transform).

Applied to files:

  • packages/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
📚 Learning: 2025-08-06T13:28:57.182Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1453
File: vitest.config.ts:49-61
Timestamp: 2025-08-06T13:28:57.182Z
Learning: In the lynx-family/lynx-stack repository, the file `packages/rspeedy/create-rspeedy/template-react-vitest-rltl-js/vitest.config.js` is a template file for scaffolding new Rspeedy projects, not a test configuration that should be included in the main vitest projects array.

Applied to files:

  • packages/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
📚 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/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
📚 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/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
📚 Learning: 2025-08-13T09:20:00.936Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1502
File: packages/react/testing-library/types/entry.d.ts:71-71
Timestamp: 2025-08-13T09:20:00.936Z
Learning: In lynx-js/react testing library, wrapper components must have children as a required prop because they are always called with `h(WrapperComponent, null, innerElement)` where innerElement is passed as children. The type `React.JSXElementConstructor<{ children: React.ReactNode }>` correctly requires children to be mandatory.

Applied to files:

  • packages/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
📚 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/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
📚 Learning: 2025-12-26T07:42:21.745Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-26T07:42:21.745Z
Learning: Applies to packages/web-platform/web-elements/**/*.ts : Use `element-reactive` patterns: inherit from `Element` (via `Component` decorator) and use reactive utilities when creating new elements

Applied to files:

  • packages/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: build / Build (Ubuntu)
  • GitHub Check: build / Build (Windows)
  • GitHub Check: test-rust / Test (Ubuntu)
  • GitHub Check: test-rust / clippy
🔇 Additional comments (2)
packages/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md (2)

51-57: Add release tag annotation to LynxTemplatePlugin interface in source code.

API Extractor detected that the LynxTemplatePlugin interface is missing an explicit release tag annotation. The source code needs a proper JSDoc tag (e.g., @public, @alpha, or @beta) above the interface declaration to satisfy API Extractor and document the stability of this newly exposed API.


8-8: API surface changes correctly expose LynxTemplatePlugin and TemplateHooks.

The type re-exports at line 35 of index.ts (export type { LynxTemplatePlugin, TemplateHooks }) align with the PR objective. The runtime exposure via api.expose(Symbol.for('LynxTemplatePlugin'), ...) in pluginReactLynx.ts (lines 376-381) correctly mirrors the type surface, wrapping LynxTemplatePlugin with the getLynxTemplatePluginHooks method.


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.

@cla-assistant
Copy link
Copy Markdown

cla-assistant Bot commented Dec 24, 2025

CLA assistant check
All committers have signed the CLA.

@upupming upupming force-pushed the feat/expose-LynxTemplatePlugin branch from f48313e to ea383ed Compare December 24, 2025 12:15
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: 2

📜 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 abd5960 and f48313e.

📒 Files selected for processing (5)
  • .changeset/thick-ideas-drum.md
  • packages/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
  • packages/rspeedy/plugin-react/src/index.ts
  • packages/rspeedy/plugin-react/src/pluginReactLynx.ts
  • packages/rspeedy/plugin-react/test/expose.test.ts
🧰 Additional context used
📓 Path-based instructions (2)
packages/**/etc/*.api.md

📄 CodeRabbit inference engine (AGENTS.md)

Always commit API extractor output after running pnpm turbo api-extractor -- --local (commit updated API report files)

Files:

  • packages/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
.changeset/*.md

📄 CodeRabbit inference engine (AGENTS.md)

For contributions, generate and commit a Changeset describing your changes

Files:

  • .changeset/thick-ideas-drum.md
🧠 Learnings (15)
📓 Common learnings
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: 1612
File: packages/rspeedy/create-rspeedy/template-react-vitest-rltl-ts/src/tsconfig.json:3-13
Timestamp: 2025-08-27T08:10:09.932Z
Learning: In the lynx-family/lynx-stack repository, Rspeedy templates use `lynx-js/rspeedy/client` types via `rspeedy-env.d.ts` instead of `vite/client` types. Rspeedy provides its own client-side environment type definitions and doesn't require direct Vite type references.
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.
📚 Learning: 2025-09-12T09:43:04.847Z
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.

Applied to files:

  • packages/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
  • packages/rspeedy/plugin-react/test/expose.test.ts
  • packages/rspeedy/plugin-react/src/pluginReactLynx.ts
  • packages/rspeedy/plugin-react/src/index.ts
  • .changeset/thick-ideas-drum.md
📚 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/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
  • packages/rspeedy/plugin-react/src/pluginReactLynx.ts
  • packages/rspeedy/plugin-react/src/index.ts
📚 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/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
  • packages/rspeedy/plugin-react/test/expose.test.ts
  • packages/rspeedy/plugin-react/src/pluginReactLynx.ts
  • packages/rspeedy/plugin-react/src/index.ts
📚 Learning: 2025-08-19T11:25:36.127Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1558
File: .changeset/solid-squids-fall.md:2-2
Timestamp: 2025-08-19T11:25:36.127Z
Learning: In the lynx-family/lynx-stack repository, changesets should use the exact package name from package.json#name, not generic or unscoped names. Each package has its own specific scoped name (e.g., "lynx-js/react-transform" for packages/react/transform).

Applied to files:

  • packages/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
  • packages/rspeedy/plugin-react/src/pluginReactLynx.ts
📚 Learning: 2025-08-06T13:28:57.182Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1453
File: vitest.config.ts:49-61
Timestamp: 2025-08-06T13:28:57.182Z
Learning: In the lynx-family/lynx-stack repository, the file `packages/rspeedy/create-rspeedy/template-react-vitest-rltl-js/vitest.config.js` is a template file for scaffolding new Rspeedy projects, not a test configuration that should be included in the main vitest projects array.

Applied to files:

  • packages/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
  • packages/rspeedy/plugin-react/test/expose.test.ts
  • packages/rspeedy/plugin-react/src/index.ts
📚 Learning: 2025-08-27T08:10:09.932Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1612
File: packages/rspeedy/create-rspeedy/template-react-vitest-rltl-ts/src/tsconfig.json:3-13
Timestamp: 2025-08-27T08:10:09.932Z
Learning: In the lynx-family/lynx-stack repository, Rspeedy templates use `lynx-js/rspeedy/client` types via `rspeedy-env.d.ts` instead of `vite/client` types. Rspeedy provides its own client-side environment type definitions and doesn't require direct Vite type references.

Applied to files:

  • packages/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
  • packages/rspeedy/plugin-react/test/expose.test.ts
  • packages/rspeedy/plugin-react/src/pluginReactLynx.ts
  • packages/rspeedy/plugin-react/src/index.ts
  • .changeset/thick-ideas-drum.md
📚 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/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
  • packages/rspeedy/plugin-react/test/expose.test.ts
  • packages/rspeedy/plugin-react/src/pluginReactLynx.ts
📚 Learning: 2025-08-06T13:28:57.182Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1453
File: vitest.config.ts:49-61
Timestamp: 2025-08-06T13:28:57.182Z
Learning: In the lynx-family/lynx-stack repository, the file `packages/react/testing-library/src/vitest.config.js` is source code for the testing library that gets exported for users, not a test configuration that should be included in the main vitest projects array.

Applied to files:

  • packages/rspeedy/plugin-react/test/expose.test.ts
📚 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/rspeedy/plugin-react/test/expose.test.ts
📚 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/rspeedy/plugin-react/test/expose.test.ts
📚 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/rspeedy/plugin-react/test/expose.test.ts
📚 Learning: 2025-08-11T05:59:28.530Z
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.

Applied to files:

  • packages/rspeedy/plugin-react/test/expose.test.ts
  • packages/rspeedy/plugin-react/src/index.ts
📚 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/rspeedy/plugin-react/src/pluginReactLynx.ts
📚 Learning: 2025-08-13T11:46:43.737Z
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.

Applied to files:

  • packages/rspeedy/plugin-react/src/index.ts
🧬 Code graph analysis (1)
packages/rspeedy/plugin-react/test/expose.test.ts (2)
packages/rspeedy/plugin-react/src/index.ts (3)
  • LynxTemplatePlugin (26-26)
  • TemplateHooks (28-28)
  • pluginReactLynx (11-11)
packages/rspeedy/plugin-react/src/pluginReactLynx.ts (1)
  • pluginReactLynx (283-392)
🔇 Additional comments (4)
packages/rspeedy/plugin-react/src/pluginReactLynx.ts (1)

24-24: LGTM!

The import and exposure of LynxTemplatePlugin follows the established pattern used for LAYERS. Using Symbol.for('LynxTemplatePlugin') ensures consistent symbol identity across the codebase.

Also applies to: 372-373

packages/rspeedy/plugin-react/src/index.ts (1)

22-30: LGTM!

The type-only exports with the guiding comment appropriately direct consumers to use api.useExposed() for runtime access, while still enabling TypeScript type checking.

packages/rspeedy/plugin-react/test/expose.test.ts (1)

12-92: Good test coverage for the new exposure mechanism.

The test comprehensively validates:

  1. Exposure is undefined before initConfigs() (lazy initialization)
  2. Exposure is available after initConfigs()
  3. The beforeEncode hook receives the expected data structure after build
packages/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md (1)

7-12: LGTM!

The API report correctly reflects the new type exports for EncodeOptions, LynxTemplatePlugin, LynxTemplatePluginOptions, and TemplateHooks. As per coding guidelines, this auto-generated file should be committed after running pnpm turbo api-extractor -- --local.

Also applies to: 44-45, 55-57, 96-97

Comment thread .changeset/thick-ideas-drum.md Outdated
Comment thread packages/rspeedy/plugin-react/test/expose.test.ts Outdated
@upupming upupming force-pushed the feat/expose-LynxTemplatePlugin branch 2 times, most recently from 7562450 to 19d816f Compare December 24, 2025 12:20
@upupming upupming force-pushed the feat/expose-LynxTemplatePlugin branch from 19d816f to 8291a27 Compare December 24, 2025 12:21
@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Dec 24, 2025

CodSpeed Performance Report

Merging #2051 will not alter performance

Comparing feat/expose-LynxTemplatePlugin (b486a4f) with main (b20e8b1)

Summary

✅ 63 untouched
⏩ 3 skipped1

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 Dec 24, 2025

React Example

#6751 Bundle Size — 237.01KiB (~+0.01%).

b486a4f(current) vs e81c190 main#6750(baseline)

Bundle metrics  Change 1 change
                 Current
#6751
     Baseline
#6750
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
No change  Cache Invalidation 38.5% 38.5%
No change  Chunks 0 0
No change  Assets 4 4
No change  Modules 162 162
No change  Duplicate Modules 65 65
Change  Duplicate Code 46.75%(+0.02%) 46.74%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  Change 1 change Regression 1 regression
                 Current
#6751
     Baseline
#6750
No change  IMG 145.76KiB 145.76KiB
Regression  Other 91.25KiB (+0.02%) 91.24KiB

Bundle analysis reportBranch feat/expose-LynxTemplatePluginProject dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci Bot commented Dec 24, 2025

Web Explorer

#6911 Bundle Size — 376.39KiB (+0.01%).

b486a4f(current) vs e81c190 main#6910(baseline)

Bundle metrics  Change 1 change Regression 1 regression
                 Current
#6911
     Baseline
#6910
Regression  Initial JS 149.87KiB(~+0.01%) 149.86KiB
No change  Initial CSS 32.4KiB 32.4KiB
No change  Cache Invalidation 55.89% 55.89%
No change  Chunks 8 8
No change  Assets 8 8
No change  Modules 232 232
No change  Duplicate Modules 16 16
No change  Duplicate Code 3.07% 3.07%
No change  Packages 4 4
No change  Duplicate Packages 0 0
Bundle size by type  Change 1 change Regression 1 regression
                 Current
#6911
     Baseline
#6910
Regression  JS 247.01KiB (+0.02%) 246.96KiB
No change  Other 96.98KiB 96.98KiB
No change  CSS 32.4KiB 32.4KiB

Bundle analysis reportBranch feat/expose-LynxTemplatePluginProject dashboard


Generated by RelativeCIDocumentationReport issue

luhc228
luhc228 previously approved these changes Dec 25, 2025
HuJean
HuJean previously approved these changes Dec 25, 2025
colinaaa
colinaaa previously approved these changes Dec 26, 2025
Comment thread packages/rspeedy/plugin-react/src/index.ts Outdated
@upupming upupming dismissed stale reviews from colinaaa, HuJean, and luhc228 via 5d906e7 December 26, 2025 03:50
@upupming upupming requested a review from colinaaa December 26, 2025 03:51
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/rspeedy/plugin-react/src/index.ts (1)

27-35: Interface wrapper provides controlled type exposure.

The approach balances convenience and coupling:

  • ✅ Provides TypeScript types without requiring consumers to install @lynx-js/template-webpack-plugin
  • ✅ Limits exposure to a single method signature
  • ⚠️ Creates type coupling: breaking changes to getLynxTemplatePluginHooks in upstream package become breaking changes here

The limited API surface (one method) reduces but doesn't eliminate this risk. The comment correctly guides users to the runtime API via api.useExposed.

Note: The interface is missing a JSDoc release tag (@public, @alpha, @beta, or @internal), which triggers the API Extractor warning in the .api.md file (line 51).

🔎 Add release tag to the interface
+/**
+ * Public interface for LynxTemplatePlugin hooks access.
+ *
+ * @public
+ */
 interface LynxTemplatePlugin {
   getLynxTemplatePluginHooks:
     typeof InnerLynxTemplatePlugin.getLynxTemplatePluginHooks
 }
📜 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 c289f83 and 5d906e7.

📒 Files selected for processing (5)
  • packages/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
  • packages/rspeedy/plugin-react/src/index.ts
  • packages/rspeedy/plugin-react/src/pluginReactLynx.ts
  • packages/rspeedy/plugin-react/test/expose.test.ts
  • packages/webpack/template-webpack-plugin/src/LynxTemplatePlugin.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/webpack/template-webpack-plugin/src/LynxTemplatePlugin.ts
🧰 Additional context used
📓 Path-based instructions (1)
packages/**/etc/*.api.md

📄 CodeRabbit inference engine (AGENTS.md)

Always commit API extractor output after running pnpm turbo api-extractor -- --local (commit updated API report files)

Files:

  • packages/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
🧠 Learnings (18)
📓 Common learnings
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: 1612
File: packages/rspeedy/create-rspeedy/template-react-vitest-rltl-ts/src/tsconfig.json:3-13
Timestamp: 2025-08-27T08:10:09.932Z
Learning: In the lynx-family/lynx-stack repository, Rspeedy templates use `lynx-js/rspeedy/client` types via `rspeedy-env.d.ts` instead of `vite/client` types. Rspeedy provides its own client-side environment type definitions and doesn't require direct Vite type references.
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1453
File: vitest.config.ts:49-61
Timestamp: 2025-08-06T13:28:57.182Z
Learning: In the lynx-family/lynx-stack repository, the file `packages/rspeedy/create-rspeedy/template-react-vitest-rltl-js/vitest.config.js` is a template file for scaffolding new Rspeedy projects, not a test configuration that should be included in the main vitest projects array.
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.
📚 Learning: 2025-08-27T08:10:09.932Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1612
File: packages/rspeedy/create-rspeedy/template-react-vitest-rltl-ts/src/tsconfig.json:3-13
Timestamp: 2025-08-27T08:10:09.932Z
Learning: In the lynx-family/lynx-stack repository, Rspeedy templates use `lynx-js/rspeedy/client` types via `rspeedy-env.d.ts` instead of `vite/client` types. Rspeedy provides its own client-side environment type definitions and doesn't require direct Vite type references.

Applied to files:

  • packages/rspeedy/plugin-react/src/index.ts
  • packages/rspeedy/plugin-react/test/expose.test.ts
  • packages/rspeedy/plugin-react/src/pluginReactLynx.ts
  • packages/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
📚 Learning: 2025-09-12T09:43:04.847Z
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.

Applied to files:

  • packages/rspeedy/plugin-react/src/index.ts
  • packages/rspeedy/plugin-react/test/expose.test.ts
  • packages/rspeedy/plugin-react/src/pluginReactLynx.ts
  • packages/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
📚 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/rspeedy/plugin-react/src/index.ts
  • packages/rspeedy/plugin-react/test/expose.test.ts
  • packages/rspeedy/plugin-react/src/pluginReactLynx.ts
  • packages/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
📚 Learning: 2025-08-06T13:28:57.182Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1453
File: vitest.config.ts:49-61
Timestamp: 2025-08-06T13:28:57.182Z
Learning: In the lynx-family/lynx-stack repository, the file `packages/rspeedy/create-rspeedy/template-react-vitest-rltl-js/vitest.config.js` is a template file for scaffolding new Rspeedy projects, not a test configuration that should be included in the main vitest projects array.

Applied to files:

  • packages/rspeedy/plugin-react/src/index.ts
  • packages/rspeedy/plugin-react/test/expose.test.ts
  • packages/rspeedy/plugin-react/src/pluginReactLynx.ts
  • packages/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
📚 Learning: 2025-08-13T11:46:43.737Z
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.

Applied to files:

  • packages/rspeedy/plugin-react/src/index.ts
📚 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/rspeedy/plugin-react/src/index.ts
  • packages/rspeedy/plugin-react/src/pluginReactLynx.ts
  • packages/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
📚 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/rspeedy/plugin-react/src/index.ts
  • packages/rspeedy/plugin-react/src/pluginReactLynx.ts
  • packages/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
📚 Learning: 2025-08-11T05:59:28.530Z
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.

Applied to files:

  • packages/rspeedy/plugin-react/src/index.ts
  • packages/rspeedy/plugin-react/test/expose.test.ts
  • packages/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
📚 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/rspeedy/plugin-react/src/index.ts
  • packages/rspeedy/plugin-react/src/pluginReactLynx.ts
📚 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/rspeedy/plugin-react/src/index.ts
  • packages/rspeedy/plugin-react/test/expose.test.ts
  • packages/rspeedy/plugin-react/src/pluginReactLynx.ts
  • packages/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
📚 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/rspeedy/plugin-react/src/index.ts
  • packages/rspeedy/plugin-react/test/expose.test.ts
📚 Learning: 2025-08-19T11:25:36.127Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1558
File: .changeset/solid-squids-fall.md:2-2
Timestamp: 2025-08-19T11:25:36.127Z
Learning: In the lynx-family/lynx-stack repository, changesets should use the exact package name from package.json#name, not generic or unscoped names. Each package has its own specific scoped name (e.g., "lynx-js/react-transform" for packages/react/transform).

Applied to files:

  • packages/rspeedy/plugin-react/src/index.ts
  • packages/rspeedy/plugin-react/src/pluginReactLynx.ts
  • packages/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
📚 Learning: 2025-08-13T09:20:00.936Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1502
File: packages/react/testing-library/types/entry.d.ts:71-71
Timestamp: 2025-08-13T09:20:00.936Z
Learning: In lynx-js/react testing library, wrapper components must have children as a required prop because they are always called with `h(WrapperComponent, null, innerElement)` where innerElement is passed as children. The type `React.JSXElementConstructor<{ children: React.ReactNode }>` correctly requires children to be mandatory.

Applied to files:

  • packages/rspeedy/plugin-react/src/index.ts
  • packages/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
📚 Learning: 2025-08-06T13:28:57.182Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1453
File: vitest.config.ts:49-61
Timestamp: 2025-08-06T13:28:57.182Z
Learning: In the lynx-family/lynx-stack repository, the file `packages/react/testing-library/src/vitest.config.js` is source code for the testing library that gets exported for users, not a test configuration that should be included in the main vitest projects array.

Applied to files:

  • packages/rspeedy/plugin-react/test/expose.test.ts
📚 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/rspeedy/plugin-react/test/expose.test.ts
📚 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/rspeedy/plugin-react/test/expose.test.ts
📚 Learning: 2025-09-12T09:43:04.847Z
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, empty changeset files (containing only `---\n\n---`) are used for internal changes that modify src/** files but don't require meaningful release notes, such as private package changes or testing-only modifications. This satisfies CI requirements without generating user-facing release notes.

Applied to files:

  • packages/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
🧬 Code graph analysis (3)
packages/rspeedy/plugin-react/src/index.ts (1)
packages/webpack/template-webpack-plugin/src/LynxTemplatePlugin.ts (1)
  • LynxTemplatePlugin (339-445)
packages/rspeedy/plugin-react/test/expose.test.ts (1)
packages/webpack/template-webpack-plugin/src/LynxTemplatePlugin.ts (7)
  • LynxTemplatePlugin (339-445)
  • TemplateHooks (83-138)
  • compilation (624-645)
  • compilation (656-713)
  • compilation (715-925)
  • compilation (956-978)
  • compilation (980-1027)
packages/rspeedy/plugin-react/src/pluginReactLynx.ts (2)
packages/rspeedy/plugin-react/src/index.ts (1)
  • LynxTemplatePlugin (35-35)
packages/webpack/template-webpack-plugin/src/LynxTemplatePlugin.ts (1)
  • LynxTemplatePlugin (339-445)
🔇 Additional comments (5)
packages/rspeedy/plugin-react/test/expose.test.ts (1)

1-94: Well-structured integration test for LynxTemplatePlugin exposure.

The test comprehensively validates the exposure mechanism:

  • Properly uses api.useExposed(Symbol.for('LynxTemplatePlugin')) to access the exposed API
  • Validates the lifecycle: undefined before initConfigs(), defined after
  • Exercises the beforeEncode hook and validates the captured data structure
  • Uses inline snapshots for maintainable assertions

The type casting at lines 43-48 is necessary to bridge Rspack and Webpack compilation types.

packages/rspeedy/plugin-react/src/pluginReactLynx.ts (2)

24-24: LGTM: Import statement for runtime exposure.

Clean import of LynxTemplatePlugin class to enable the exposure mechanism.


373-381: Properly exposes limited API surface.

The implementation correctly:

  • Uses Symbol.for('LynxTemplatePlugin') as the exposure key
  • Limits the exposed API to only getLynxTemplatePluginHooks
  • Uses .bind(LynxTemplatePlugin) to maintain the correct this context

This approach aligns with the PR objective to expose a minimal, stable API surface.

packages/rspeedy/plugin-react/src/index.ts (1)

11-14: Type-only imports maintain lightweight dependency.

Using type-only imports prevents runtime dependency on @lynx-js/template-webpack-plugin while still providing TypeScript types to consumers.

packages/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md (1)

1-97: API Extractor report correctly reflects type exports.

This generated file documents the new public API surface:

  • LynxTemplatePlugin interface exposing getLynxTemplatePluginHooks
  • TemplateHooks type re-export

The warning at line 51 about the missing release tag should be resolved by adding a JSDoc release tag to the LynxTemplatePlugin interface in packages/rspeedy/plugin-react/src/index.ts (see comment on that file).

As per coding guidelines, this API Extractor output is correctly committed.

@upupming upupming force-pushed the feat/expose-LynxTemplatePlugin branch from 5d906e7 to b486a4f Compare December 29, 2025 08:29
@colinaaa colinaaa merged commit 917ae6a into main Dec 29, 2025
75 of 77 checks passed
@colinaaa colinaaa deleted the feat/expose-LynxTemplatePlugin branch December 29, 2025 09:58
colinaaa pushed a commit that referenced this pull request Jan 4, 2026
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/gesture-runtime@2.1.1

### Patch Changes

- Add `NativeGesture`
([#2076](#2076))

## @lynx-js/react@0.115.3

### Patch Changes

- Add dual-thread commutation logs for troubleshooting when
`REACT_ALOG=true` or global define `__ALOG__` is set.
([#2081](#2081))

- Use error cause to simplify the error msg of lazy bundle loading. User
can catch the error cause to get the original result:
([#2056](#2056))

    ```ts
    const LazyComponent = lazy(async () => {
      try {
        const mod = await import("./lazy-bundle");
        return mod.default;
      } catch (error) {
console.error(`Lazy Bundle load failed message: ${error.message}`);
        // User can catch the error cause to get the original result
        console.error(`Lazy Bundle load failed result: ${error.cause}`);
        throw error;
      }
    });
    ```

## @lynx-js/rspeedy@0.12.5

### Patch Changes

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

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

### Patch Changes

-   ([#2051](#2051))

-   Updated dependencies \[]:
    -   @lynx-js/react-alias-rsbuild-plugin@0.12.4
    -   @lynx-js/use-sync-external-store@1.5.0
    -   @lynx-js/react-refresh-webpack-plugin@0.3.4
    -   @lynx-js/react-webpack-plugin@0.7.3

## @lynx-js/testing-environment@0.1.9

### Patch Changes

- Fix duplicated `<page />` elements on body when multiple
`__CreatePage` called.
([#2065](#2065))

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

### Patch Changes

- Updated dependencies
\[[`bba05e2`](bba05e2)]:
    -   @lynx-js/web-worker-rpc@0.19.4

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

### Patch Changes

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

## @lynx-js/web-elements@0.10.1

### Patch Changes

- feat: implement x-webview component
([#2061](#2061))

- feat: support `recyclable="false"` on `list-item` and enable overflow
visibility
([#2069](#2069))

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

### Patch Changes

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

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

### Patch Changes

- Ensure the `default` export entry is last in the package exports map.
([#2075](#2075))

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

### Patch Changes

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

## create-rspeedy@0.12.5



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



## upgrade-rspeedy@0.12.5



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



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

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.

[Feature]: Expose the LynxTemplatePlugin to allow access TemplateHooks

4 participants