Skip to content

feat: add globalPropsMode option to PluginReactLynxOptions#2346

Merged
HuJean merged 2 commits intomainfrom
p/globalPropsMode
Mar 20, 2026
Merged

feat: add globalPropsMode option to PluginReactLynxOptions#2346
HuJean merged 2 commits intomainfrom
p/globalPropsMode

Conversation

@HuJean
Copy link
Copy Markdown
Collaborator

@HuJean HuJean commented Mar 18, 2026

Summary by CodeRabbit

  • New Features
    • Added configurable globalPropsMode (defaults to "reactive" or "event") and exported GlobalProps APIs: GlobalPropsProvider, GlobalPropsConsumer, useGlobalProps, useGlobalPropsChanged.
  • Tests
    • Added tests covering both modes, integration flows, and injected runtime flag behavior.
  • Chores
    • Minor version bumps and updated plugin/config to surface the new option.
  • Documentation
    • API docs updated to document globalPropsMode and the GlobalProps exports.

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 Mar 18, 2026

🦋 Changeset detected

Latest commit: 63151bc

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-rsbuild-plugin Minor
@lynx-js/react-webpack-plugin Minor
@lynx-js/react-umd Minor
@lynx-js/react-alias-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

@HuJean HuJean marked this pull request as ready for review March 18, 2026 07:42
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 18, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a globalPropsMode option (<'reactive' | 'event'>, default 'reactive') across plugin & webpack config, injects runtime __GLOBAL_PROPS_MODE__, implements event-mode branching in updateGlobalProps, and exposes GlobalProps Provider/Consumer/hooks with tests covering both modes.

Changes

Cohort / File(s) Summary
Runtime core & API
packages/react/runtime/src/lynx/tt.ts, packages/react/runtime/src/lynx-api.ts
updateGlobalProps now branches on __GLOBAL_PROPS_MODE__ (preserve reactive behavior vs copy-on-write event mode and skip forced root re-render); emit onGlobalPropsChanged payload; add GlobalPropsProvider, GlobalPropsConsumer, useGlobalProps, useGlobalPropsChanged, and dev warning for non-event fallback.
Runtime types & compat exports
packages/react/runtime/types/types.d.ts, packages/react/runtime/lazy/compat.js
Declare global __GLOBAL_PROPS_MODE__ type and export GlobalProps provider/consumer and hooks from compat surface.
Runtime tests & test globals
packages/react/runtime/__test__/lifecycle/updateGlobalProps.test.jsx, packages/react/runtime/__test__/utils/globals.js, packages/webpack/react-refresh-webpack-plugin/test/setup-env.js
Expanded updateGlobalProps tests with main/background/hydration/event-mode scenarios; add test setup/teardown to initialize/reset __GLOBAL_PROPS_MODE__.
Webpack plugin: options, define injection & tests
packages/webpack/react-webpack-plugin/src/ReactWebpackPlugin.ts, packages/webpack/react-webpack-plugin/test/..., packages/webpack/react-webpack-plugin/test/cases/define/global-props-mode-event/*
Add globalPropsMode option/default to plugin options, inject __GLOBAL_PROPS_MODE__ via DefinePlugin, add tests/fixtures verifying both 'reactive' and 'event' injection.
rspeedy plugin: public option & forwarding
packages/rspeedy/plugin-react/src/pluginReactLynx.ts, packages/rspeedy/plugin-react/src/entry.ts, packages/rspeedy/plugin-react/test/config.test.ts, packages/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
Add `globalPropsMode?: 'reactive'
Docs / Changesets / API md
.changeset/thirty-cycles-find.md, .changeset/funny-weeks-stand.md, packages/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md, packages/webpack/react-webpack-plugin/etc/react-webpack-plugin.api.md
Add changesets for minor releases and document new globalPropsMode option and newly exported GlobalProps APIs in API markdown files.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • hzy
  • colinaaa
  • luhc228
  • upupming

Poem

🐰 I nibble code and hop through lines of green,
Event or reactive, choose the mode unseen.
Props may whisper softly or ring like a bell,
I twitch my whiskers and test every swell,
A happy rabbit cheering the build machine.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.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 describes the primary change: adding a new globalPropsMode option to PluginReactLynxOptions. It is concise, clear, and directly reflects the main objective of the pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch p/globalPropsMode
📝 Coding Plan
  • Generate coding plan for human review comments

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 Mar 18, 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!

@HuJean HuJean force-pushed the p/globalPropsMode branch from 5569f88 to 1b05a51 Compare March 18, 2026 07:50
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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/react/runtime/__test__/lifecycle/updateGlobalProps.test.jsx`:
- Around line 25-28: The test suite sets the shared global flag
__GLOBAL_PROPS_MODE__ in one test but currently only restores it later; make the
reset unconditional by adding a line to set __GLOBAL_PROPS_MODE__ back to its
default (e.g., undefined or the suite default) inside the existing afterEach
block that calls vi.restoreAllMocks() and elementTree.clear(), so that any
override introduced (the test that sets __GLOBAL_PROPS_MODE__ to 'event') cannot
leak into subsequent tests.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b8e201a9-e866-44cc-8e1b-225835f263aa

📥 Commits

Reviewing files that changed from the base of the PR and between 3eceeeb and 5569f88.

📒 Files selected for processing (11)
  • .changeset/thirty-cycles-find.md
  • packages/react/runtime/__test__/lifecycle/updateGlobalProps.test.jsx
  • packages/react/runtime/__test__/utils/globals.js
  • packages/react/runtime/src/lynx/tt.ts
  • packages/react/runtime/types/types.d.ts
  • packages/rspeedy/plugin-react/src/entry.ts
  • packages/rspeedy/plugin-react/src/pluginReactLynx.ts
  • packages/rspeedy/plugin-react/test/config.test.ts
  • packages/webpack/react-refresh-webpack-plugin/test/setup-env.js
  • packages/webpack/react-webpack-plugin/src/ReactWebpackPlugin.ts
  • packages/webpack/react-webpack-plugin/test/setup-env.js

@HuJean HuJean force-pushed the p/globalPropsMode branch from 1b05a51 to 09b16b3 Compare March 18, 2026 07:59
@relativeci
Copy link
Copy Markdown

relativeci Bot commented Mar 18, 2026

Web Explorer

#8291 Bundle Size — 385.21KiB (0%).

63151bc(current) vs 726f600 main#8237(baseline)

Bundle metrics  no changes
                 Current
#8291
     Baseline
#8237
No change  Initial JS 155.59KiB 155.59KiB
No change  Initial CSS 35.1KiB 35.1KiB
No change  Cache Invalidation 0% 0%
No change  Chunks 8 8
No change  Assets 8 8
No change  Modules 238 238
No change  Duplicate Modules 16 16
No change  Duplicate Code 2.97% 2.97%
No change  Packages 4 4
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#8291
     Baseline
#8237
No change  JS 254.26KiB 254.26KiB
No change  Other 95.85KiB 95.85KiB
No change  CSS 35.1KiB 35.1KiB

Bundle analysis reportBranch p/globalPropsModeProject dashboard


Generated by RelativeCIDocumentationReport issue

@HuJean HuJean requested a review from Huxpro March 18, 2026 08:04
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.

♻️ Duplicate comments (1)
packages/react/runtime/__test__/lifecycle/updateGlobalProps.test.jsx (1)

25-28: ⚠️ Potential issue | 🟡 Minor

Make __GLOBAL_PROPS_MODE__ reset unconditional in shared cleanup.

If this test fails before Line 184, 'event' can leak into later tests. Move the reset into afterEach to guarantee isolation.

♻️ Proposed fix
 afterEach(() => {
+  globalThis.__GLOBAL_PROPS_MODE__ = 'reactive';
   vi.restoreAllMocks();
   elementTree.clear();
 });
@@
-    globalThis.__GLOBAL_PROPS_MODE__ = 'reactive';
   });

Also applies to: 184-184

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

In `@packages/react/runtime/__test__/lifecycle/updateGlobalProps.test.jsx` around
lines 25 - 28, The test suite must unconditionally reset __GLOBAL_PROPS_MODE__
in shared cleanup to avoid leaking an 'event' into later tests; update the
afterEach block that currently calls vi.restoreAllMocks() and
elementTree.clear() to also reset __GLOBAL_PROPS_MODE__ to its default (e.g.,
false or undefined depending on your convention) so the reset always runs
regardless of where a test fails; locate the afterEach function in this file and
add the unconditional reset alongside elementTree.clear() and
vi.restoreAllMocks() to ensure isolation for subsequent tests.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@packages/react/runtime/__test__/lifecycle/updateGlobalProps.test.jsx`:
- Around line 25-28: The test suite must unconditionally reset
__GLOBAL_PROPS_MODE__ in shared cleanup to avoid leaking an 'event' into later
tests; update the afterEach block that currently calls vi.restoreAllMocks() and
elementTree.clear() to also reset __GLOBAL_PROPS_MODE__ to its default (e.g.,
false or undefined depending on your convention) so the reset always runs
regardless of where a test fails; locate the afterEach function in this file and
add the unconditional reset alongside elementTree.clear() and
vi.restoreAllMocks() to ensure isolation for subsequent tests.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 651f83f0-5031-4eab-9dc0-062acfc139c3

📥 Commits

Reviewing files that changed from the base of the PR and between 1b05a51 and 09b16b3.

📒 Files selected for processing (17)
  • .changeset/thirty-cycles-find.md
  • packages/react/runtime/__test__/lifecycle/updateGlobalProps.test.jsx
  • packages/react/runtime/__test__/utils/globals.js
  • packages/react/runtime/src/lynx/tt.ts
  • packages/react/runtime/types/types.d.ts
  • packages/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
  • packages/rspeedy/plugin-react/src/entry.ts
  • packages/rspeedy/plugin-react/src/pluginReactLynx.ts
  • packages/rspeedy/plugin-react/test/config.test.ts
  • packages/webpack/react-refresh-webpack-plugin/test/setup-env.js
  • packages/webpack/react-webpack-plugin/etc/react-webpack-plugin.api.md
  • packages/webpack/react-webpack-plugin/src/ReactWebpackPlugin.ts
  • packages/webpack/react-webpack-plugin/test/cases/define/default/index.jsx
  • packages/webpack/react-webpack-plugin/test/cases/define/global-props-mode-event/index.jsx
  • packages/webpack/react-webpack-plugin/test/cases/define/global-props-mode-event/rspack.config.js
  • packages/webpack/react-webpack-plugin/test/cases/define/global-props-mode-event/test.config.cjs
  • packages/webpack/react-webpack-plugin/test/setup-env.js
🚧 Files skipped from review as they are similar to previous changes (6)
  • .changeset/thirty-cycles-find.md
  • packages/webpack/react-webpack-plugin/test/setup-env.js
  • packages/react/runtime/test/utils/globals.js
  • packages/react/runtime/types/types.d.ts
  • packages/webpack/react-webpack-plugin/test/cases/define/global-props-mode-event/test.config.cjs
  • packages/webpack/react-webpack-plugin/src/ReactWebpackPlugin.ts

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Mar 18, 2026

Merging this PR will degrade performance by 8.36%

❌ 1 regressed benchmark
✅ 71 untouched benchmarks
⏩ 3 skipped benchmarks1

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

Performance Changes

Benchmark BASE HEAD Efficiency
transform 1000 view elements 43.4 ms 47.3 ms -8.36%

Comparing p/globalPropsMode (63151bc) with main (726f600)

Open in CodSpeed

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.

@HuJean HuJean force-pushed the p/globalPropsMode branch 2 times, most recently from 3136372 to 7869e12 Compare March 19, 2026 02:31
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: 1

🧹 Nitpick comments (1)
packages/react/runtime/src/lynx-api.ts (1)

222-250: Consider deduplicating the warning to avoid console spam.

warnGlobalPropsMode() is called on every render of Provider, Consumer, and every invocation of use(). In a large app tree, this could produce excessive console warnings. Consider using a module-level flag to warn only once.

♻️ Suggested pattern for one-time warning
+let didWarnGlobalPropsMode = false;
+
 function warnGlobalPropsMode() {
+  if (didWarnGlobalPropsMode) return;
   if (typeof __LEPUS__ !== 'undefined' && !__LEPUS__ && typeof __DEV__ !== 'undefined' && __DEV__) {
+    didWarnGlobalPropsMode = true;
     console.warn(
       `This API does not need to be used when 'globalPropsMode' is not 'event', `
         + `updates will be triggered automatically by full re-render. `
         + `Please set 'globalPropsMode' to 'event' to enable optimized updates.`,
     );
   }
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/react/runtime/src/lynx-api.ts` around lines 222 - 250, The repeated
warnGlobalPropsMode() calls in createFallbackGlobalProps (affecting Provider,
Consumer, and use) will spam the console; add a module-level boolean flag (e.g.,
warnedGlobalPropsMode) and guard calls so the warning is emitted only once, or
make warnGlobalPropsMode itself idempotent by returning early when the flag is
set; update the calls in createFallbackGlobalProps (Provider, Consumer, use) to
check/set this flag before invoking the warning while leaving useChanged and its
__LEPUS__/useLynxGlobalEventListener behavior unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/react/runtime/src/lynx-api.ts`:
- Around line 212-220: The warning message in warnGlobalPropsMode has awkward
grammar ("is no need to use"); update the console.warn string in function
warnGlobalPropsMode to a clearer phrasing such as: "This API is not needed when
'globalPropsMode' is not 'event'; updates will be triggered automatically by a
full re-render. Please set 'globalPropsMode' to 'event' to enable optimized
updates." Replace the existing message in warnGlobalPropsMode with this improved
wording.

---

Nitpick comments:
In `@packages/react/runtime/src/lynx-api.ts`:
- Around line 222-250: The repeated warnGlobalPropsMode() calls in
createFallbackGlobalProps (affecting Provider, Consumer, and use) will spam the
console; add a module-level boolean flag (e.g., warnedGlobalPropsMode) and guard
calls so the warning is emitted only once, or make warnGlobalPropsMode itself
idempotent by returning early when the flag is set; update the calls in
createFallbackGlobalProps (Provider, Consumer, use) to check/set this flag
before invoking the warning while leaving useChanged and its
__LEPUS__/useLynxGlobalEventListener behavior unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 91f04917-ceac-446a-b28c-8bb8a51f8b9c

📥 Commits

Reviewing files that changed from the base of the PR and between 09b16b3 and 3136372.

📒 Files selected for processing (20)
  • .changeset/funny-weeks-stand.md
  • .changeset/thirty-cycles-find.md
  • packages/react/runtime/__test__/lifecycle/updateGlobalProps.test.jsx
  • packages/react/runtime/__test__/utils/globals.js
  • packages/react/runtime/lazy/compat.js
  • packages/react/runtime/src/lynx-api.ts
  • packages/react/runtime/src/lynx/tt.ts
  • packages/react/runtime/types/types.d.ts
  • packages/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
  • packages/rspeedy/plugin-react/src/entry.ts
  • packages/rspeedy/plugin-react/src/pluginReactLynx.ts
  • packages/rspeedy/plugin-react/test/config.test.ts
  • packages/webpack/react-refresh-webpack-plugin/test/setup-env.js
  • packages/webpack/react-webpack-plugin/etc/react-webpack-plugin.api.md
  • packages/webpack/react-webpack-plugin/src/ReactWebpackPlugin.ts
  • packages/webpack/react-webpack-plugin/test/cases/define/default/index.jsx
  • packages/webpack/react-webpack-plugin/test/cases/define/global-props-mode-event/index.jsx
  • packages/webpack/react-webpack-plugin/test/cases/define/global-props-mode-event/rspack.config.js
  • packages/webpack/react-webpack-plugin/test/cases/define/global-props-mode-event/test.config.cjs
  • packages/webpack/react-webpack-plugin/test/setup-env.js
✅ Files skipped from review due to trivial changes (9)
  • packages/webpack/react-webpack-plugin/test/cases/define/default/index.jsx
  • packages/webpack/react-webpack-plugin/test/cases/define/global-props-mode-event/rspack.config.js
  • packages/webpack/react-webpack-plugin/etc/react-webpack-plugin.api.md
  • packages/webpack/react-webpack-plugin/test/cases/define/global-props-mode-event/index.jsx
  • .changeset/funny-weeks-stand.md
  • packages/webpack/react-refresh-webpack-plugin/test/setup-env.js
  • packages/webpack/react-webpack-plugin/test/cases/define/global-props-mode-event/test.config.cjs
  • .changeset/thirty-cycles-find.md
  • packages/rspeedy/plugin-react/test/config.test.ts
🚧 Files skipped from review as they are similar to previous changes (7)
  • packages/rspeedy/plugin-react/etc/react-rsbuild-plugin.api.md
  • packages/react/runtime/types/types.d.ts
  • packages/react/runtime/test/utils/globals.js
  • packages/webpack/react-webpack-plugin/test/setup-env.js
  • packages/rspeedy/plugin-react/src/pluginReactLynx.ts
  • packages/webpack/react-webpack-plugin/src/ReactWebpackPlugin.ts
  • packages/react/runtime/test/lifecycle/updateGlobalProps.test.jsx

Comment thread packages/react/runtime/src/lynx-api.ts
@HuJean HuJean force-pushed the p/globalPropsMode branch from 7869e12 to 7dd963f Compare March 19, 2026 02:32
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/react/runtime/__test__/lifecycle/updateGlobalProps.test.jsx (1)

272-360: Unused imports in test.

Lines 274-276 import GlobalPropsProvider and GlobalPropsConsumer but they are not used in this test case. Consider removing them to keep the imports clean.

♻️ Suggested fix
-    const { useGlobalProps, useGlobalPropsChanged, GlobalPropsProvider, GlobalPropsConsumer } = await import(
+    const { useGlobalProps, useGlobalPropsChanged } = await import(
       '../../src/lynx-api'
     );
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/react/runtime/__test__/lifecycle/updateGlobalProps.test.jsx` around
lines 272 - 360, The test imports unused symbols GlobalPropsProvider and
GlobalPropsConsumer from '../../src/lynx-api'; remove those unused imports and
only destructure the needed hooks (useGlobalProps and useGlobalPropsChanged)
from the import statement so the import becomes minimal and no unused
identifiers remain.
🤖 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/react/runtime/__test__/lifecycle/updateGlobalProps.test.jsx`:
- Around line 272-360: The test imports unused symbols GlobalPropsProvider and
GlobalPropsConsumer from '../../src/lynx-api'; remove those unused imports and
only destructure the needed hooks (useGlobalProps and useGlobalPropsChanged)
from the import statement so the import becomes minimal and no unused
identifiers remain.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1394cb5a-d610-4cf7-93f8-5a2efd32eef8

📥 Commits

Reviewing files that changed from the base of the PR and between 3136372 and 7dd963f.

📒 Files selected for processing (6)
  • .changeset/funny-weeks-stand.md
  • .changeset/thirty-cycles-find.md
  • packages/react/runtime/__test__/lifecycle/updateGlobalProps.test.jsx
  • packages/react/runtime/lazy/compat.js
  • packages/react/runtime/src/lynx-api.ts
  • packages/react/runtime/src/lynx/tt.ts
✅ Files skipped from review due to trivial changes (2)
  • .changeset/thirty-cycles-find.md
  • .changeset/funny-weeks-stand.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/react/runtime/lazy/compat.js

@HuJean HuJean force-pushed the p/globalPropsMode branch 4 times, most recently from 3446ee7 to f2bb346 Compare March 19, 2026 12:07
Comment thread .changeset/thirty-cycles-find.md
Yradex
Yradex previously approved these changes Mar 20, 2026
Copy link
Copy Markdown
Collaborator

@Yradex Yradex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to check react-webpack-plugin later.

@HuJean HuJean force-pushed the p/globalPropsMode branch from f2bb346 to 219a837 Compare March 20, 2026 06:08
Yradex
Yradex previously approved these changes Mar 20, 2026
@HuJean HuJean enabled auto-merge (squash) March 20, 2026 06:15
@HuJean HuJean force-pushed the p/globalPropsMode branch from 219a837 to bace8a7 Compare March 20, 2026 06:30
Comment thread packages/react/runtime/src/lynx/tt.ts Outdated
Comment thread packages/react/runtime/src/lynx-api.ts
Comment thread packages/rspeedy/plugin-react/src/pluginReactLynx.ts
Comment thread packages/react/runtime/src/lynx-api.ts
@HuJean HuJean force-pushed the p/globalPropsMode branch from bace8a7 to 1402d2e Compare March 20, 2026 06:55
…Props` and `useGlobalPropsChanged` for `__globalProps`
@HuJean HuJean force-pushed the p/globalPropsMode branch from 1402d2e to 63151bc Compare March 20, 2026 07:10
@HuJean HuJean merged commit 402ec2b into main Mar 20, 2026
81 of 83 checks passed
@HuJean HuJean deleted the p/globalPropsMode branch March 20, 2026 08:53
colinaaa pushed a commit that referenced this pull request Mar 24, 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/react@0.117.0

### Minor Changes

- feat: export `GlobalPropsProvider`, `GlobalPropsConsumer`,
`useGlobalProps` and `useGlobalPropsChanged` for `__globalProps`
([#2346](#2346))

- `GlobalPropsProvider`: A Provider component that accepts `children`.
It is used to provide the `lynx.__globalProps` context.
- `GlobalPropsConsumer`: A Consumer component that accepts a function as
a child. It is used to consume the `lynx.__globalProps` context.
- `useGlobalProps`: A hook that returns the `lynx.__globalProps` object.
It triggers a re-render when `lynx.__globalProps` changes.
- `useGlobalPropsChanged`: A hook that accepts a callback function. The
callback is invoked when `lynx.__globalProps` changes.

Note: When `globalPropsMode` is not set to `'event'` (default is
`'reactive'`), these APIs will be ineffective (pass-through) and will
log a warning in development mode, as updates are triggered
automatically by full re-render.

- **BREAKING CHANGE**:
([#2319](#2319))

Change preact package from `@hongzhiyuan/preact` to
`@lynx-js/internal-preact`.

Upgrade preact from
[f7693b72](preactjs/preact@f7693b7)
to
[55254ef7](preactjs/preact@55254ef),
see diffs at
[f7693b72...55254ef7](https://github.com/preactjs/preact/compare/f7693b72ecb4a40c66e6e47f54e2d4edc374c9f0...preactjs:preact:55254ef7021e563cc1a86fb816058964a1b6a29a?expand=1).

- feat: add `globalPropsMode` option to `PluginReactLynxOptions`
([#2346](#2346))

- When configured to `"event"`, `updateGlobalProps` will only trigger a
global event and skip the `runWithForce` flow.
- Defaults to `"reactive"`, which means `updateGlobalProps` will trigger
re-render automatically.

### Patch Changes

- Add `__BACKGROUND__` guard on `onBackgroundSnapshotInstanceUpdateId`
event to prevent bundling to main-thread on dev environment.
([#2332](#2332))

- refactor: extract static string in template literal
([#2334](#2334))

- fix: avoid crash when spread undefined ref
([#2333](#2333))

- Avoid registering lifecycle refs for main-thread functions (MTF) that
have not received an `execId` during `renderPage()` first-screen
binding. ([#2320](#2320))

## @lynx-js/react-umd@0.117.0

### Minor Changes

- Add standalone UMD build of the ReactLynx runtime.
([#2331](#2331))

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

### Minor Changes

- **BREAKING CHANGE**:
([#2319](#2319))

Change preact package from `@hongzhiyuan/preact` to
`@lynx-js/internal-preact`.

Upgrade preact from
[f7693b72](preactjs/preact@f7693b7)
to
[55254ef7](preactjs/preact@55254ef),
see diffs at
[f7693b72...55254ef7](https://github.com/preactjs/preact/compare/f7693b72ecb4a40c66e6e47f54e2d4edc374c9f0...preactjs:preact:55254ef7021e563cc1a86fb816058964a1b6a29a?expand=1).

- feat: add `globalPropsMode` option to `PluginReactLynxOptions`
([#2346](#2346))

- When configured to `"event"`, `updateGlobalProps` will only trigger a
global event and skip the `runWithForce` flow.
- Defaults to `"reactive"`, which means `updateGlobalProps` will trigger
re-render automatically.

### Patch Changes

- Updated dependencies
\[[`f1129ea`](f1129ea),
[`27f1cff`](27f1cff),
[`ed566f0`](ed566f0),
[`402ec2b`](402ec2b)]:
    -   @lynx-js/react-webpack-plugin@0.8.0
    -   @lynx-js/react-refresh-webpack-plugin@0.3.5
    -   @lynx-js/react-alias-rsbuild-plugin@0.13.0
    -   @lynx-js/use-sync-external-store@1.5.0
    -   @lynx-js/template-webpack-plugin@0.10.6
    -   @lynx-js/css-extract-webpack-plugin@0.7.0

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

### Minor Changes

- feat: add `globalPropsMode` option to `PluginReactLynxOptions`
([#2346](#2346))

- When configured to `"event"`, `updateGlobalProps` will only trigger a
global event and skip the `runWithForce` flow.
- Defaults to `"reactive"`, which means `updateGlobalProps` will trigger
re-render automatically.

### Patch Changes

- Fix sourcemap misalignment when wrapping lazy bundle main-thread
chunks. ([#2361](#2361))

The lazy bundle IIFE wrapper is now injected in `processAssets` at
`PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE + 1` by walking chunk groups instead
of patching assets in `beforeEncode`.

- With `experimental_isLazyBundle: true`, the wrapper is applied to
lazy-bundle chunk groups.
- Without lazy bundle mode, the wrapper is applied to async main-thread
chunk groups generated by dynamic import.

Injecting the wrapper in this stage keeps the emitted JS stable after
optimization while still running before `DEV_TOOLING` sourcemap
finalization, so the generated `.js` and `.js.map` stay aligned.

- Set `__DEV__` and `__PROFILE__` to `true` on `NODE_ENV ===
'development'`.
([#2324](#2324))

## @lynx-js/rspeedy@0.13.6

### Patch Changes

- Rename Web Preview label to fix URL alignment
([#2355](#2355))

- Updated dependencies
\[[`799fda8`](799fda8)]:
    -   @lynx-js/cache-events-webpack-plugin@0.0.3
    -   @lynx-js/web-rsbuild-server-middleware@0.19.9

## @lynx-js/lynx-bundle-rslib-config@0.2.3

### Patch Changes

- Fix snapshot not found error when dev with external bundle
([#2316](#2316))

## @lynx-js/external-bundle-rsbuild-plugin@0.0.4

### Patch Changes

- Updated dependencies
\[[`ed566f0`](ed566f0)]:
    -   @lynx-js/externals-loading-webpack-plugin@0.0.5

## @lynx-js/kitten-lynx-test-infra@0.1.1

### Patch Changes

- feat: support page.screenshot()
([#2364](#2364))

- feat: initial commit
([#2272](#2272))

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

### Patch Changes

- Implement `__ElementAnimate` PAPI for web platform animation lifecycle
([#2329](#2329))

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

### Patch Changes

- Implement `__ElementAnimate` PAPI for web platform animation lifecycle
([#2329](#2329))

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

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

### Patch Changes

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

## @lynx-js/web-core-wasm@0.0.6

### Patch Changes

- reexports essential utils & types in @lynx-js/web-elements from
@lynx-js/web-core-wasm/client
([#2321](#2321))

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

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

### Patch Changes

- Updated dependencies
\[[`2efecc2`](2efecc2)]:
    -   @lynx-js/web-constants@0.19.9

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

### Patch Changes

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

## @lynx-js/cache-events-webpack-plugin@0.0.3

### Patch Changes

- Cache `globalThis.loadDynamicComponent` in the cache events runtime
and add tests covering tt methods, performance events, and globalThis
replay behavior.
([#2343](#2343))

## @lynx-js/externals-loading-webpack-plugin@0.0.5

### Patch Changes

- Fix snapshot not found error when dev with external bundle
([#2316](#2316))

## @lynx-js/react-refresh-webpack-plugin@0.3.5

### Patch Changes

- Fix snapshot not found error when dev with external bundle
([#2316](#2316))

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

### Patch Changes

- Updated dependencies
\[[`d034dae`](d034dae)]:
    -   @lynx-js/web-core-wasm@0.0.6

## create-rspeedy@0.13.6



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



## upgrade-rspeedy@0.13.6



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



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



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

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants