Skip to content

chore: migrate to @lynx-js/internal-preact#2319

Merged
upupming merged 2 commits intomainfrom
chore/preact
Mar 16, 2026
Merged

chore: migrate to @lynx-js/internal-preact#2319
upupming merged 2 commits intomainfrom
chore/preact

Conversation

@upupming
Copy link
Copy Markdown
Collaborator

@upupming upupming commented Mar 9, 2026

See:

Fix in #2003 has been reverted because Preact has fixed it in https://github.com/preactjs/preact/pull/4999/changes

Summary by CodeRabbit

  • Chores
    • Published a patch bump for the React package in project metadata.
    • Switched to an internal Preact implementation for dependency resolution; public APIs unchanged.
    • Adjusted runtime internals affecting DOM insertion behavior without public API signature changes.
    • Broadened module detection for bundling to include the internal Preact variants.
  • Tests
    • Updated test expectations to match the new internal Preact resolution.

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

@upupming upupming requested review from HuJean, Yradex and hzy as code owners March 9, 2026 08:36
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 9, 2026

🦋 Changeset detected

Latest commit: 4c6bf2e

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

This PR includes changesets to release 3 packages
Name Type
@lynx-js/react Minor
@lynx-js/react-rsbuild-plugin 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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 9, 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

Replaced preact resolution to @lynx-js/internal-preact across package.json, aliases, tests and bundling patterns; removed a private isDetached check so appendChild always delegates to insertBefore; added a changeset documenting a patch bump for @lynx-js/react.

Changes

Cohort / File(s) Summary
Changeset Documentation
\.changeset/swift-pots-teach.md
Added a new changeset recording a patch bump for @lynx-js/react and the preact dependency change.
React package manifest
packages/react/package.json
Updated dependencies["preact"] from npm:@hongzhiyuan/preact@10.28.0-fc4af453 to npm:@lynx-js/internal-preact@10.28.4-ee7bb26.
Runtime snapshot
packages/react/runtime/src/backgroundSnapshot.ts
Removed private isDetached getter and traversal; appendChild now always calls insertBefore (conditional guard removed).
Alias & bundling tests
packages/rspeedy/lynx-bundle-rslib-config/test/external-bundle.test.ts, packages/rspeedy/plugin-react/test/config.test.ts, packages/rspeedy/plugin-react-alias/test/index.test.ts
Updated test expectations to reference @lynx-js/internal-preact/... instead of @hongzhiyuan/preact/....
SplitChunks / bundle config
packages/rspeedy/plugin-react/src/splitChunks.ts, packages/webpack/react-webpack-plugin/test/cases/.../rspack.config.js
Expanded preact cacheGroup test to match internal-preact variants in addition to existing preact patterns.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • hzy
  • colinaaa
  • luhc228
  • HuJean
  • Yradex

Poem

🐇 I hopped through package.json tonight,
Swapped preact paths by lantern light,
Tests now whisper internal names,
Snapshots trimmed of old detach claims,
A tiny changeset — code feels light.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'chore: migrate to @lynx-js/internal-preact' clearly and concisely describes the main change—migrating the preact dependency to @lynx-js/internal-preact across the codebase.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/preact

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 9, 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!

@upupming upupming changed the title chore migrate @hongzhiyuan/preact to @lynx-js/internal-preact chore: migrate @hongzhiyuan/preact to @lynx-js/internal-preact Mar 9, 2026
@upupming upupming changed the title chore: migrate @hongzhiyuan/preact to @lynx-js/internal-preact chore: migrate to @lynx-js/internal-preact Mar 9, 2026
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/package.json`:
- Line 177: The external-bundle test expectations still reference the old
package layout "@hongzhiyuan/preact" while package.json maps "preact" to
"@lynx-js/internal-preact"; update the test assertions in
external-bundle.test.ts to replace every "@hongzhiyuan/preact" (and any paths
prefixed with that, e.g. "preact" or "preact/*") with the new
"@lynx-js/internal-preact" equivalents so the expected resolved bundle paths
match the migrated package name.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f8dc59d1-bec5-44c9-ba3b-e95510486dc2

📥 Commits

Reviewing files that changed from the base of the PR and between f730d3c and 6827657.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • .changeset/swift-pots-teach.md
  • packages/react/package.json

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 9, 2026

Merging this PR will degrade performance by 10.28%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

❌ 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
basic-performance-small-css 7.5 ms 8.4 ms -10.28%

Comparing chore/preact (4c6bf2e) with main (27f1cff)

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.

@relativeci
Copy link
Copy Markdown

relativeci bot commented Mar 9, 2026

Web Explorer

#8170 Bundle Size — 384.5KiB (0%).

4c6bf2e(current) vs e6dac46 main#8164(baseline)

Bundle metrics  Change 1 change
                 Current
#8170
     Baseline
#8164
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
Change  Modules 238(-0.42%) 239
No change  Duplicate Modules 16 16
No change  Duplicate Code 2.98% 2.98%
No change  Packages 4 4
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#8170
     Baseline
#8164
No change  JS 253.55KiB 253.55KiB
No change  Other 95.85KiB 95.85KiB
No change  CSS 35.1KiB 35.1KiB

Bundle analysis reportBranch chore/preactProject dashboard


Generated by RelativeCIDocumentationReport issue

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 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/src/backgroundSnapshot.ts`:
- Around line 87-90: The appendChild implementation should avoid emitting live
InsertBefore patches when the parent or any ancestor is marked detached (the
__removed_from_tree flag); update BackgroundSnapshotInstance.appendChild (which
currently calls insertBefore) to detect whether this instance or any ancestor is
removed and, if so, do not call insertBefore (instead defer the mutation so it
will be handled by reconstructInstanceTree later), ensuring the
snapshotPatchApply eager InsertBefore path (see snapshotPatchApply.ts) is not
triggered for detached subtrees; use the same removed-ancestor check logic used
by removeChild/reconstructInstanceTree to decide to queue/defer rather than
perform insertBefore.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8594d0cf-f6fb-43b3-80d8-dd3dbb3db918

📥 Commits

Reviewing files that changed from the base of the PR and between e225d4b and b3e4bf2.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (5)
  • .changeset/swift-pots-teach.md
  • packages/react/package.json
  • packages/react/runtime/src/backgroundSnapshot.ts
  • packages/rspeedy/lynx-bundle-rslib-config/test/external-bundle.test.ts
  • packages/rspeedy/plugin-react/test/config.test.ts

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/rspeedy/plugin-react/src/splitChunks.ts`:
- Around line 64-69: The preact split group regex in extraGroups['preact']
doesn't match subpaths of internal-preact (e.g., internal-preact/compat); update
the test pattern used in the extraGroups['preact'] object so it uses a single
alternation that allows an optional "internal-" prefix and optional subpaths,
i.e., replace the existing alternation with one like
(?:internal-)?preact(?:[\\/](?:compat|hooks|jsx-runtime))? so that
internal-preact and its compat/hooks/jsx-runtime subpaths all match and are
grouped into 'lib-preact'.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2f1f849b-e34b-43a2-9661-635020772287

📥 Commits

Reviewing files that changed from the base of the PR and between b3e4bf2 and 8470b31.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (8)
  • .changeset/swift-pots-teach.md
  • packages/react/package.json
  • packages/react/runtime/src/backgroundSnapshot.ts
  • packages/rspeedy/lynx-bundle-rslib-config/test/external-bundle.test.ts
  • packages/rspeedy/plugin-react-alias/test/index.test.ts
  • packages/rspeedy/plugin-react/src/splitChunks.ts
  • packages/rspeedy/plugin-react/test/config.test.ts
  • packages/webpack/react-webpack-plugin/test/cases/basic/bundle-splitting/rspack.config.js
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/rspeedy/plugin-react/test/config.test.ts
  • .changeset/swift-pots-teach.md
  • packages/rspeedy/lynx-bundle-rslib-config/test/external-bundle.test.ts

@upupming upupming merged commit 0991136 into main Mar 16, 2026
77 of 81 checks passed
@upupming upupming deleted the chore/preact branch March 16, 2026 10:49
@coderabbitai coderabbitai bot mentioned this pull request Mar 20, 2026
3 tasks
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>
@coderabbitai coderabbitai bot mentioned this pull request Mar 27, 2026
3 tasks
@coderabbitai coderabbitai bot mentioned this pull request Apr 14, 2026
3 tasks
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