feat: expose LynxTemplatePlugin to rsbuild API#2051
Conversation
🦋 Changeset detectedLatest commit: b486a4f The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
📝 WalkthroughWalkthroughThis change exposes the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (6)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (4)
🧰 Additional context used🧠 Learnings (14)📓 Common learnings📚 Learning: 2025-09-12T09:43:04.847ZApplied to files:
📚 Learning: 2025-12-26T05:10:01.595ZApplied to files:
📚 Learning: 2025-12-26T05:10:01.595ZApplied to files:
📚 Learning: 2025-09-18T04:43:54.426ZApplied to files:
📚 Learning: 2025-12-26T05:10:01.595ZApplied to files:
📚 Learning: 2025-08-27T08:10:09.932ZApplied to files:
📚 Learning: 2025-08-19T11:25:36.127ZApplied to files:
📚 Learning: 2025-08-06T13:28:57.182ZApplied to files:
📚 Learning: 2025-08-12T16:09:32.413ZApplied to files:
📚 Learning: 2025-09-18T04:43:54.426ZApplied to files:
📚 Learning: 2025-08-13T09:20:00.936ZApplied to files:
📚 Learning: 2025-08-27T12:42:01.095ZApplied to files:
📚 Learning: 2025-12-26T07:42:21.745ZApplied to files:
⏰ 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)
🔇 Additional comments (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
f48313e to
ea383ed
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
.changeset/thick-ideas-drum.mdpackages/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.mdpackages/rspeedy/plugin-react/src/index.tspackages/rspeedy/plugin-react/src/pluginReactLynx.tspackages/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.mdpackages/rspeedy/plugin-react/test/expose.test.tspackages/rspeedy/plugin-react/src/pluginReactLynx.tspackages/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.mdpackages/rspeedy/plugin-react/src/pluginReactLynx.tspackages/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.mdpackages/rspeedy/plugin-react/test/expose.test.tspackages/rspeedy/plugin-react/src/pluginReactLynx.tspackages/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.mdpackages/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.mdpackages/rspeedy/plugin-react/test/expose.test.tspackages/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.mdpackages/rspeedy/plugin-react/test/expose.test.tspackages/rspeedy/plugin-react/src/pluginReactLynx.tspackages/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.mdpackages/rspeedy/plugin-react/test/expose.test.tspackages/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.tspackages/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
LynxTemplatePluginfollows the established pattern used forLAYERS. UsingSymbol.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:
- Exposure is
undefinedbeforeinitConfigs()(lazy initialization)- Exposure is available after
initConfigs()- The
beforeEncodehook receives the expected data structure after buildpackages/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, andTemplateHooks. As per coding guidelines, this auto-generated file should be committed after runningpnpm turbo api-extractor -- --local.Also applies to: 44-45, 55-57, 96-97
7562450 to
19d816f
Compare
19d816f to
8291a27
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
CodSpeed Performance ReportMerging #2051 will not alter performanceComparing Summary
Footnotes
|
React Example#6751 Bundle Size — 237.01KiB (~+0.01%).b486a4f(current) vs e81c190 main#6750(baseline) Bundle metrics
Bundle size by type
Bundle analysis report Branch feat/expose-LynxTemplatePlugin Project dashboard Generated by RelativeCI Documentation Report issue |
Web Explorer#6911 Bundle Size — 376.39KiB (+0.01%).b486a4f(current) vs e81c190 main#6910(baseline) Bundle metrics
Bundle size by type
Bundle analysis report Branch feat/expose-LynxTemplatePlugin Project dashboard Generated by RelativeCI Documentation Report issue |
There was a problem hiding this comment.
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 togetLynxTemplatePluginHooksin upstream package become breaking changes hereThe 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.mdfile (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
📒 Files selected for processing (5)
packages/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.mdpackages/rspeedy/plugin-react/src/index.tspackages/rspeedy/plugin-react/src/pluginReactLynx.tspackages/rspeedy/plugin-react/test/expose.test.tspackages/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.tspackages/rspeedy/plugin-react/test/expose.test.tspackages/rspeedy/plugin-react/src/pluginReactLynx.tspackages/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.tspackages/rspeedy/plugin-react/test/expose.test.tspackages/rspeedy/plugin-react/src/pluginReactLynx.tspackages/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.tspackages/rspeedy/plugin-react/test/expose.test.tspackages/rspeedy/plugin-react/src/pluginReactLynx.tspackages/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.tspackages/rspeedy/plugin-react/test/expose.test.tspackages/rspeedy/plugin-react/src/pluginReactLynx.tspackages/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.tspackages/rspeedy/plugin-react/src/pluginReactLynx.tspackages/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.tspackages/rspeedy/plugin-react/src/pluginReactLynx.tspackages/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.tspackages/rspeedy/plugin-react/test/expose.test.tspackages/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.tspackages/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.tspackages/rspeedy/plugin-react/test/expose.test.tspackages/rspeedy/plugin-react/src/pluginReactLynx.tspackages/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.tspackages/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.tspackages/rspeedy/plugin-react/src/pluginReactLynx.tspackages/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.tspackages/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
beforeEncodehook 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
LynxTemplatePluginclass 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 correctthiscontextThis 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-pluginwhile 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:
LynxTemplatePlugininterface exposinggetLynxTemplatePluginHooksTemplateHookstype re-exportThe warning at line 51 about the missing release tag should be resolved by adding a JSDoc release tag to the
LynxTemplatePlugininterface inpackages/rspeedy/plugin-react/src/index.ts(see comment on that file).As per coding guidelines, this API Extractor output is correctly committed.
5d906e7 to
b486a4f
Compare
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>
Summary by CodeRabbit
New Features
Tests
Documentation
Chores
✏️ Tip: You can customize this high-level summary in your review settings.
resolve: #2044
Checklist