Skip to content

feat: export constants in @lynx-js/react/constants#2451

Closed
HuJean wants to merge 1 commit intomainfrom
p/constants
Closed

feat: export constants in @lynx-js/react/constants#2451
HuJean wants to merge 1 commit intomainfrom
p/constants

Conversation

@HuJean
Copy link
Copy Markdown
Collaborator

@HuJean HuJean commented Apr 11, 2026

Summary by CodeRabbit

  • New Features

    • Constants previously internal are now published as a public API: CHILDREN, COMPONENT, DIFF, DIRTY, DOM, FLAGS, INDEX, PARENT.
  • Chores

    • Package and build/plugin configurations updated to expose and lazily resolve the new constants entry; tests updated to cover the new export and alias behavior.

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 Apr 11, 2026

🦋 Changeset detected

Latest commit: 4f000e3

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

This PR includes changesets to release 5 packages
Name Type
@lynx-js/react Minor
@lynx-js/react-umd Minor
@lynx-js/react-alias-rsbuild-plugin Minor
@lynx-js/lynx-bundle-rslib-config Minor
@lynx-js/react-rsbuild-plugin Minor

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 Apr 11, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8421e5c9-6892-4cbe-8592-478772ff65f7

📥 Commits

Reviewing files that changed from the base of the PR and between 6d8ac35 and 4f000e3.

📒 Files selected for processing (23)
  • .changeset/tidy-buttons-tie.md
  • packages/react-umd/src/index.ts
  • packages/react/package.json
  • packages/react/runtime/__test__/lazy.test.js
  • packages/react/runtime/lazy/constants.js
  • packages/react/runtime/lazy/import.js
  • packages/react/runtime/lazy/internal.js
  • packages/react/runtime/lazy/target.js
  • packages/react/runtime/lepus/jsx-runtime/index.js
  • packages/react/runtime/src/constants.ts
  • packages/react/runtime/src/internal.ts
  • packages/react/runtime/vitest.config.ts
  • packages/rspeedy/lynx-bundle-rslib-config/src/externalBundleRslibConfig.ts
  • packages/rspeedy/lynx-bundle-rslib-config/test/external-bundle.test.ts
  • packages/rspeedy/plugin-external-bundle/src/index.ts
  • packages/rspeedy/plugin-react-alias/src/index.ts
  • packages/rspeedy/plugin-react-alias/test/index.test.ts
  • packages/rspeedy/plugin-react/package.json
  • packages/rspeedy/plugin-react/test/config.test.ts
  • packages/rspeedy/plugin-react/test/lazy.test.ts
  • packages/webpack/react-webpack-plugin/test/cases/basic/lazy-imports/index.jsx
  • packages/webpack/react-webpack-plugin/test/cases/code-splitting/lazy-imports/index.jsx
  • packages/webpack/react-webpack-plugin/test/cases/compat/component-is/index.jsx
💤 Files with no reviewable changes (2)
  • packages/react/runtime/lazy/internal.js
  • packages/react/runtime/src/internal.ts
✅ Files skipped from review due to trivial changes (11)
  • packages/react-umd/src/index.ts
  • packages/react/runtime/vitest.config.ts
  • packages/rspeedy/plugin-react/test/config.test.ts
  • packages/webpack/react-webpack-plugin/test/cases/compat/component-is/index.jsx
  • packages/react/runtime/test/lazy.test.js
  • packages/react/runtime/lepus/jsx-runtime/index.js
  • packages/rspeedy/lynx-bundle-rslib-config/src/externalBundleRslibConfig.ts
  • packages/react/runtime/lazy/constants.js
  • packages/rspeedy/plugin-react-alias/test/index.test.ts
  • packages/rspeedy/plugin-react/package.json
  • packages/react/runtime/src/constants.ts
🚧 Files skipped from review as they are similar to previous changes (8)
  • packages/react/runtime/lazy/target.js
  • packages/webpack/react-webpack-plugin/test/cases/basic/lazy-imports/index.jsx
  • packages/rspeedy/plugin-react/test/lazy.test.ts
  • packages/rspeedy/plugin-react-alias/src/index.ts
  • packages/react/runtime/lazy/import.js
  • packages/webpack/react-webpack-plugin/test/cases/code-splitting/lazy-imports/index.jsx
  • packages/react/package.json
  • packages/rspeedy/plugin-external-bundle/src/index.ts

📝 Walkthrough

Walkthrough

Adds a public @lynx-js/react/constants subpath and lazy load wiring for React opcode constants, moves usages from internal to the new constants surface, updates UMD exports, adjusts rspeedy externals/alias rules, and expands test coverage for the new alias and lazy exports.

Changes

Cohort / File(s) Summary
Changeset & package export
\.changeset/tidy-buttons-tie.md, packages/react/package.json
Added changeset and new ./constants package export (types, lazy, default) and typesVersions mapping.
Runtime constants module
packages/react/runtime/src/constants.ts, packages/react/runtime/lazy/constants.js
Created runtime re-export entry and lazy constants module exporting opcode identifiers (CHILDREN, COMPONENT, DIFF, DIRTY, DOM, FLAGS, INDEX, PARENT).
Lazy export orchestration
packages/react/runtime/lazy/target.js, packages/react/runtime/lazy/import.js, packages/react/runtime/lazy/internal.js
Added Symbol key for constants, registered ReactConstants on lazy target, and removed constants from internal destructuring.
Runtime consumers
packages/react/runtime/src/internal.ts, packages/react/runtime/lepus/jsx-runtime/index.js, packages/react-umd/src/index.ts
Moved imports to use @lynx-js/react/constants; updated JSX runtime import and added export * as ReactConstants to UMD entry.
Vitest/test config
packages/react/runtime/__test__/lazy.test.js, packages/react/runtime/vitest.config.ts
Added lazy parity test for constants and Vitest alias resolving @lynx-js/react/constants to runtime src.
Rspeedy externals & aliasing
packages/rspeedy/lynx-bundle-rslib-config/src/externalBundleRslibConfig.ts, packages/rspeedy/plugin-external-bundle/src/index.ts, packages/rspeedy/plugin-react-alias/src/index.ts, packages/rspeedy/plugin-react/package.json
Added externals mapping and plugin externals entry for @lynx-js/react/constants; added constants transformed entry and loosened peerDependency range to include ^0.119.0.
Rspeedy & webpack tests
packages/rspeedy/plugin-react-alias/test/index.test.ts, packages/rspeedy/plugin-react/test/*.ts, packages/rspeedy/lynx-bundle-rslib-config/test/external-bundle.test.ts, packages/webpack/.../test/cases/*/index.jsx
Updated tests and snapshots to expect @lynx-js/react/constants$ alias and added lazy-import symbol assertions for the constants export across lazy/import tests.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • hzy
  • colinaaa
  • luhc228

Poem

🐇 I tunneled through code to make constants bright,
A new subpath blossoms in morning light.
Symbols and lazy loads now dance in a row,
Bundles and tests learn the name they should know.
Hooray — hop, patch, and off I go!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the primary change: exporting constants from a new @lynx-js/react/constants module, which is the core objective reflected throughout all file changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch p/constants

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.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 11, 2026

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!

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.

🧹 Nitpick comments (1)
packages/rspeedy/plugin-react/test/config.test.ts (1)

81-83: Strengthen non-lazy alias coverage for constants.

These checks validate the non-anchored key is absent, but they don’t verify that @lynx-js/react/constants$ is actually wired in non-lazy mode. Adding a positive assertion would make this test stricter and prevent silent regressions.

Proposed test hardening
     expect(config.resolve.alias).not.toHaveProperty(
       '@lynx-js/react/constants',
     )
+    expect(config.resolve.alias).toHaveProperty(
+      '@lynx-js/react/constants$',
+      expect.stringContaining(
+        '/packages/react/runtime/lib/constants.js'.replaceAll('/', path.sep),
+      ),
+    )
     expect(config.resolve.alias).not.toHaveProperty(
       '@lynx-js/react/constants',
     )
+    expect(config.resolve.alias).toHaveProperty(
+      '@lynx-js/react/constants$',
+      expect.stringContaining(
+        '/packages/react/runtime/lib/constants.js'.replaceAll('/', path.sep),
+      ),
+    )

Also applies to: 291-293

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/rspeedy/plugin-react/test/config.test.ts` around lines 81 - 83, The
test currently asserts config.resolve.alias does not have the non-anchored key
'@lynx-js/react/constants' but misses a positive check that the anchored
non-lazy alias '@lynx-js/react/constants$' is present and points to the expected
non-lazy module; update the assertions in the test (near the existing checks
referencing config.resolve.alias) to also assert that config.resolve.alias
hasOwnProperty('@lynx-js/react/constants$') and that its value equals the
expected resolved path/string used for non-lazy constants (repeat the same
strengthened positive assertion at the other location around lines where similar
negative checks occur, previously referenced as 291-293) so the test guarantees
the non-lazy alias is wired correctly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/rspeedy/plugin-react/test/config.test.ts`:
- Around line 81-83: The test currently asserts config.resolve.alias does not
have the non-anchored key '@lynx-js/react/constants' but misses a positive check
that the anchored non-lazy alias '@lynx-js/react/constants$' is present and
points to the expected non-lazy module; update the assertions in the test (near
the existing checks referencing config.resolve.alias) to also assert that
config.resolve.alias hasOwnProperty('@lynx-js/react/constants$') and that its
value equals the expected resolved path/string used for non-lazy constants
(repeat the same strengthened positive assertion at the other location around
lines where similar negative checks occur, previously referenced as 291-293) so
the test guarantees the non-lazy alias is wired correctly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f1be41e4-3691-4701-8404-1758c2b351f9

📥 Commits

Reviewing files that changed from the base of the PR and between dc3b6e0 and 6d8ac35.

📒 Files selected for processing (22)
  • .changeset/tidy-buttons-tie.md
  • packages/react-umd/src/index.ts
  • packages/react/package.json
  • packages/react/runtime/__test__/lazy.test.js
  • packages/react/runtime/lazy/constants.js
  • packages/react/runtime/lazy/import.js
  • packages/react/runtime/lazy/internal.js
  • packages/react/runtime/lazy/target.js
  • packages/react/runtime/lepus/jsx-runtime/index.js
  • packages/react/runtime/src/constants.ts
  • packages/react/runtime/src/internal.ts
  • packages/react/runtime/vitest.config.ts
  • packages/rspeedy/lynx-bundle-rslib-config/src/externalBundleRslibConfig.ts
  • packages/rspeedy/plugin-external-bundle/src/index.ts
  • packages/rspeedy/plugin-react-alias/src/index.ts
  • packages/rspeedy/plugin-react-alias/test/index.test.ts
  • packages/rspeedy/plugin-react/package.json
  • packages/rspeedy/plugin-react/test/config.test.ts
  • packages/rspeedy/plugin-react/test/lazy.test.ts
  • packages/webpack/react-webpack-plugin/test/cases/basic/lazy-imports/index.jsx
  • packages/webpack/react-webpack-plugin/test/cases/code-splitting/lazy-imports/index.jsx
  • packages/webpack/react-webpack-plugin/test/cases/compat/component-is/index.jsx
💤 Files with no reviewable changes (2)
  • packages/react/runtime/lazy/internal.js
  • packages/react/runtime/src/internal.ts

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 11, 2026

Merging this PR will not alter performance

✅ 81 untouched benchmarks
⏩ 21 skipped benchmarks1


Comparing p/constants (4f000e3) with main (dc3b6e0)

Open in CodSpeed

Footnotes

  1. 21 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 Apr 11, 2026

React External

#337 Bundle Size — 590.61KiB (+0.08%).

4f000e3(current) vs dc3b6e0 main#330(baseline)

Bundle metrics  Change 1 change
                 Current
#337
     Baseline
#330
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
Change  Cache Invalidation 30.88% 0%
No change  Chunks 0 0
No change  Assets 3 3
No change  Modules 17 17
No change  Duplicate Modules 5 5
No change  Duplicate Code 8.59% 8.59%
No change  Packages 0 0
No change  Duplicate Packages 0 0
Bundle size by type  Change 1 change Regression 1 regression
                 Current
#337
     Baseline
#330
Regression  Other 590.61KiB (+0.08%) 590.13KiB

Bundle analysis reportBranch p/constantsProject dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci bot commented Apr 11, 2026

Web Explorer

#8793 Bundle Size — 743.45KiB (0%).

4f000e3(current) vs dc3b6e0 main#8786(baseline)

Bundle metrics  Change 2 changes
                 Current
#8793
     Baseline
#8786
No change  Initial JS 43.82KiB 43.82KiB
No change  Initial CSS 2.16KiB 2.16KiB
No change  Cache Invalidation 0% 0%
No change  Chunks 8 8
No change  Assets 10 10
Change  Modules 147(-1.34%) 149
No change  Duplicate Modules 11 11
Change  Duplicate Code 34.98%(+0.03%) 34.97%
No change  Packages 3 3
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#8793
     Baseline
#8786
No change  Other 398.15KiB 398.15KiB
No change  JS 343.13KiB 343.13KiB
No change  CSS 2.16KiB 2.16KiB

Bundle analysis reportBranch p/constantsProject dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci bot commented Apr 11, 2026

React Example

#7219 Bundle Size — 236.82KiB (0%).

4f000e3(current) vs dc3b6e0 main#7212(baseline)

Bundle metrics  no changes
                 Current
#7219
     Baseline
#7212
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
No change  Cache Invalidation 0% 0%
No change  Chunks 0 0
No change  Assets 4 4
No change  Modules 179 179
No change  Duplicate Modules 70 70
No change  Duplicate Code 46.1% 46.1%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#7219
     Baseline
#7212
No change  IMG 145.76KiB 145.76KiB
No change  Other 91.06KiB 91.06KiB

Bundle analysis reportBranch p/constantsProject dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci bot commented Apr 11, 2026

React MTF Example

#352 Bundle Size — 206.11KiB (0%).

4f000e3(current) vs dc3b6e0 main#345(baseline)

Bundle metrics  no changes
                 Current
#352
     Baseline
#345
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
No change  Cache Invalidation 0% 0%
No change  Chunks 0 0
No change  Assets 3 3
No change  Modules 173 173
No change  Duplicate Modules 67 67
No change  Duplicate Code 45.76% 45.76%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#352
     Baseline
#345
No change  IMG 111.23KiB 111.23KiB
No change  Other 94.88KiB 94.88KiB

Bundle analysis reportBranch p/constantsProject dashboard


Generated by RelativeCIDocumentationReport issue

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.

1 participant