From e33774097da510c8ffa825fcf88ac76465296909 Mon Sep 17 00:00:00 2001 From: Yiming Li Date: Mon, 9 Mar 2026 16:35:40 +0800 Subject: [PATCH 1/2] chore: migrate @hongzhiyuan/preact to @lynx-js/internal-preact --- .changeset/swift-pots-teach.md | 6 ++ packages/react/package.json | 2 +- .../react/runtime/src/backgroundSnapshot.ts | 15 +---- .../test/external-bundle.test.ts | 26 ++++----- .../plugin-react-alias/test/index.test.ts | 56 +++++++++++++----- .../rspeedy/plugin-react/src/splitChunks.ts | 2 +- .../rspeedy/plugin-react/test/config.test.ts | 58 ++++++++++++++----- .../basic/bundle-splitting/rspack.config.js | 2 +- pnpm-lock.yaml | 14 ++--- 9 files changed, 117 insertions(+), 64 deletions(-) create mode 100644 .changeset/swift-pots-teach.md diff --git a/.changeset/swift-pots-teach.md b/.changeset/swift-pots-teach.md new file mode 100644 index 0000000000..71a31ffe3d --- /dev/null +++ b/.changeset/swift-pots-teach.md @@ -0,0 +1,6 @@ +--- +"@lynx-js/react": patch +"@lynx-js/react-rsbuild-plugin": patch +--- + +Change preact package from `@hongzhiyuan/preact` to `@lynx-js/internal-preact`. diff --git a/packages/react/package.json b/packages/react/package.json index a8af7cf395..80ee11c4f6 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -174,7 +174,7 @@ "api-extractor": "api-extractor run --verbose" }, "dependencies": { - "preact": "npm:@hongzhiyuan/preact@10.28.0-fc4af453" + "preact": "npm:@lynx-js/internal-preact@10.28.4-ee7bb26" }, "devDependencies": { "@lynx-js/types": "3.7.0", diff --git a/packages/react/runtime/src/backgroundSnapshot.ts b/packages/react/runtime/src/backgroundSnapshot.ts index bf134d5915..47282612b6 100644 --- a/packages/react/runtime/src/backgroundSnapshot.ts +++ b/packages/react/runtime/src/backgroundSnapshot.ts @@ -68,17 +68,6 @@ export class BackgroundSnapshotInstance { private __nextSibling: BackgroundSnapshotInstance | null = null; private __removed_from_tree?: boolean; - private get isDetached(): boolean { - let node: BackgroundSnapshotInstance | null = this; - while (node) { - if (node.__removed_from_tree) { - return true; - } - node = node.__parent; - } - return false; - } - get parentNode(): BackgroundSnapshotInstance | null { return this.__parent; } @@ -97,9 +86,7 @@ export class BackgroundSnapshotInstance { // This will be called in `lazy`/`Suspense`. appendChild(child: BackgroundSnapshotInstance): void { - if (!this.isDetached) { - return this.insertBefore(child); - } + return this.insertBefore(child); } insertBefore( diff --git a/packages/rspeedy/lynx-bundle-rslib-config/test/external-bundle.test.ts b/packages/rspeedy/lynx-bundle-rslib-config/test/external-bundle.test.ts index 4ee438ba5f..5eb0a62aec 100644 --- a/packages/rspeedy/lynx-bundle-rslib-config/test/external-bundle.test.ts +++ b/packages/rspeedy/lynx-bundle-rslib-config/test/external-bundle.test.ts @@ -385,19 +385,19 @@ describe('pluginReactLynx', () => { "@lynx-js/react/runtime-components$": "/packages/react/components/lib/index.js", "@lynx-js/react/worklet-runtime/bindings$": "/packages/react/worklet-runtime/lib/bindings/index.js", "@swc/helpers": "/node_modules//@swc/helpers", - "preact$": "/node_modules//@hongzhiyuan/preact/dist/preact.mjs", - "preact/compat$": "/node_modules//@hongzhiyuan/preact/compat/dist/compat.mjs", - "preact/compat/client$": "/node_modules//@hongzhiyuan/preact/compat/client.mjs", - "preact/compat/jsx-dev-runtime$": "/node_modules//@hongzhiyuan/preact/compat/jsx-dev-runtime.mjs", - "preact/compat/jsx-runtime$": "/node_modules//@hongzhiyuan/preact/compat/jsx-runtime.mjs", - "preact/compat/scheduler$": "/node_modules//@hongzhiyuan/preact/compat/scheduler.mjs", - "preact/compat/server$": "/node_modules//@hongzhiyuan/preact/compat/server.mjs", - "preact/debug$": "/node_modules//@hongzhiyuan/preact/debug/dist/debug.mjs", - "preact/devtools$": "/node_modules//@hongzhiyuan/preact/devtools/dist/devtools.mjs", - "preact/hooks$": "/node_modules//@hongzhiyuan/preact/hooks/dist/hooks.mjs", - "preact/jsx-dev-runtime$": "/node_modules//@hongzhiyuan/preact/jsx-runtime/dist/jsxRuntime.mjs", - "preact/jsx-runtime$": "/node_modules//@hongzhiyuan/preact/jsx-runtime/dist/jsxRuntime.mjs", - "preact/test-utils$": "/node_modules//@hongzhiyuan/preact/test-utils/dist/testUtils.mjs", + "preact$": "/node_modules//@lynx-js/internal-preact/dist/preact.mjs", + "preact/compat$": "/node_modules//@lynx-js/internal-preact/compat/dist/compat.mjs", + "preact/compat/client$": "/node_modules//@lynx-js/internal-preact/compat/client.mjs", + "preact/compat/jsx-dev-runtime$": "/node_modules//@lynx-js/internal-preact/compat/jsx-dev-runtime.mjs", + "preact/compat/jsx-runtime$": "/node_modules//@lynx-js/internal-preact/compat/jsx-runtime.mjs", + "preact/compat/scheduler$": "/node_modules//@lynx-js/internal-preact/compat/scheduler.mjs", + "preact/compat/server$": "/node_modules//@lynx-js/internal-preact/compat/server.mjs", + "preact/debug$": "/node_modules//@lynx-js/internal-preact/debug/dist/debug.mjs", + "preact/devtools$": "/node_modules//@lynx-js/internal-preact/devtools/dist/devtools.mjs", + "preact/hooks$": "/node_modules//@lynx-js/internal-preact/hooks/dist/hooks.mjs", + "preact/jsx-dev-runtime$": "/node_modules//@lynx-js/internal-preact/jsx-runtime/dist/jsxRuntime.mjs", + "preact/jsx-runtime$": "/node_modules//@lynx-js/internal-preact/jsx-runtime/dist/jsxRuntime.mjs", + "preact/test-utils$": "/node_modules//@lynx-js/internal-preact/test-utils/dist/testUtils.mjs", "react$": "/packages/react/runtime/lib/index.js", "react-compiler-runtime": "/node_modules//react-compiler-runtime", "use-sync-external-store$": "/packages/use-sync-external-store/index.js", diff --git a/packages/rspeedy/plugin-react-alias/test/index.test.ts b/packages/rspeedy/plugin-react-alias/test/index.test.ts index 74ccd88e85..b573576ae3 100644 --- a/packages/rspeedy/plugin-react-alias/test/index.test.ts +++ b/packages/rspeedy/plugin-react-alias/test/index.test.ts @@ -75,79 +75,109 @@ describe('React - alias', () => { expect(config.resolve.alias).toHaveProperty( 'preact$', expect.stringContaining( - '/preact/dist/preact.mjs'.replaceAll('/', path.sep), + '@lynx-js/internal-preact/dist/preact.mjs'.replaceAll('/', path.sep), ), ) expect(config.resolve.alias).toHaveProperty( 'preact/compat$', expect.stringContaining( - '/preact/compat/dist/compat.mjs'.replaceAll('/', path.sep), + '@lynx-js/internal-preact/compat/dist/compat.mjs'.replaceAll( + '/', + path.sep, + ), ), ) expect(config.resolve.alias).toHaveProperty( 'preact/debug$', expect.stringContaining( - '/preact/debug/dist/debug.mjs'.replaceAll('/', path.sep), + '@lynx-js/internal-preact/debug/dist/debug.mjs'.replaceAll( + '/', + path.sep, + ), ), ) expect(config.resolve.alias).toHaveProperty( 'preact/devtools$', expect.stringContaining( - '/preact/devtools/dist/devtools.mjs'.replaceAll('/', path.sep), + '@lynx-js/internal-preact/devtools/dist/devtools.mjs'.replaceAll( + '/', + path.sep, + ), ), ) expect(config.resolve.alias).toHaveProperty( 'preact/hooks$', expect.stringContaining( - '/preact/hooks/dist/hooks.mjs'.replaceAll('/', path.sep), + '@lynx-js/internal-preact/hooks/dist/hooks.mjs'.replaceAll( + '/', + path.sep, + ), ), ) expect(config.resolve.alias).toHaveProperty( 'preact/test-utils$', expect.stringContaining( - '/preact/test-utils/dist/testUtils.mjs'.replaceAll('/', path.sep), + '@lynx-js/internal-preact/test-utils/dist/testUtils.mjs'.replaceAll( + '/', + path.sep, + ), ), ) expect(config.resolve.alias).toHaveProperty( 'preact/jsx-runtime$', expect.stringContaining( - '/preact/jsx-runtime/dist/jsxRuntime.mjs'.replaceAll('/', path.sep), + '@lynx-js/internal-preact/jsx-runtime/dist/jsxRuntime.mjs'.replaceAll( + '/', + path.sep, + ), ), ) expect(config.resolve.alias).toHaveProperty( 'preact/jsx-dev-runtime$', expect.stringContaining( - '/preact/jsx-runtime/dist/jsxRuntime.mjs'.replaceAll('/', path.sep), + '@lynx-js/internal-preact/jsx-runtime/dist/jsxRuntime.mjs'.replaceAll( + '/', + path.sep, + ), ), ) expect(config.resolve.alias).toHaveProperty( 'preact/compat/client$', expect.stringContaining( - '/preact/compat/client.mjs'.replaceAll('/', path.sep), + '@lynx-js/internal-preact/compat/client.mjs'.replaceAll('/', path.sep), ), ) expect(config.resolve.alias).toHaveProperty( 'preact/compat/server$', expect.stringContaining( - '/preact/compat/server.mjs'.replaceAll('/', path.sep), + '@lynx-js/internal-preact/compat/server.mjs'.replaceAll('/', path.sep), ), ) expect(config.resolve.alias).toHaveProperty( 'preact/compat/jsx-runtime$', expect.stringContaining( - '/preact/compat/jsx-runtime.mjs'.replaceAll('/', path.sep), + '@lynx-js/internal-preact/compat/jsx-runtime.mjs'.replaceAll( + '/', + path.sep, + ), ), ) expect(config.resolve.alias).toHaveProperty( 'preact/compat/jsx-dev-runtime$', expect.stringContaining( - '/preact/compat/jsx-dev-runtime.mjs'.replaceAll('/', path.sep), + '@lynx-js/internal-preact/compat/jsx-dev-runtime.mjs'.replaceAll( + '/', + path.sep, + ), ), ) expect(config.resolve.alias).toHaveProperty( 'preact/compat/scheduler$', expect.stringContaining( - '/preact/compat/scheduler.mjs'.replaceAll('/', path.sep), + '@lynx-js/internal-preact/compat/scheduler.mjs'.replaceAll( + '/', + path.sep, + ), ), ) }) diff --git a/packages/rspeedy/plugin-react/src/splitChunks.ts b/packages/rspeedy/plugin-react/src/splitChunks.ts index 08c385e747..27149f715c 100644 --- a/packages/rspeedy/plugin-react/src/splitChunks.ts +++ b/packages/rspeedy/plugin-react/src/splitChunks.ts @@ -64,7 +64,7 @@ export const applySplitChunksRule: ( extraGroups['preact'] = { name: 'lib-preact', test: - /node_modules[\\/](.*?[\\/])?(?:preact|preact[\\/]compat|preact[\\/]hooks|preact[\\/]jsx-runtime)[\\/]/, + /node_modules[\\/](.*?[\\/])?(?:(?:internal-)?preact|(?:internal-)?preact[\\/]compat|(?:internal-)?preact[\\/]hooks|(?:internal-)?preact[\\/]jsx-runtime)[\\/]/, priority: 0, } diff --git a/packages/rspeedy/plugin-react/test/config.test.ts b/packages/rspeedy/plugin-react/test/config.test.ts index 3c0e9559ff..b07cab109c 100644 --- a/packages/rspeedy/plugin-react/test/config.test.ts +++ b/packages/rspeedy/plugin-react/test/config.test.ts @@ -81,79 +81,109 @@ describe('Config', () => { expect(config.resolve.alias).toHaveProperty( 'preact$', expect.stringContaining( - '/preact/dist/preact.mjs'.replaceAll('/', path.sep), + '@lynx-js/internal-preact/dist/preact.mjs'.replaceAll('/', path.sep), ), ) expect(config.resolve.alias).toHaveProperty( 'preact/compat$', expect.stringContaining( - '/preact/compat/dist/compat.mjs'.replaceAll('/', path.sep), + '@lynx-js/internal-preact/compat/dist/compat.mjs'.replaceAll( + '/', + path.sep, + ), ), ) expect(config.resolve.alias).toHaveProperty( 'preact/debug$', expect.stringContaining( - '/preact/debug/dist/debug.mjs'.replaceAll('/', path.sep), + '@lynx-js/internal-preact/debug/dist/debug.mjs'.replaceAll( + '/', + path.sep, + ), ), ) expect(config.resolve.alias).toHaveProperty( 'preact/devtools$', expect.stringContaining( - '/preact/devtools/dist/devtools.mjs'.replaceAll('/', path.sep), + '@lynx-js/internal-preact/devtools/dist/devtools.mjs'.replaceAll( + '/', + path.sep, + ), ), ) expect(config.resolve.alias).toHaveProperty( 'preact/hooks$', expect.stringContaining( - '/preact/hooks/dist/hooks.mjs'.replaceAll('/', path.sep), + '@lynx-js/internal-preact/hooks/dist/hooks.mjs'.replaceAll( + '/', + path.sep, + ), ), ) expect(config.resolve.alias).toHaveProperty( 'preact/test-utils$', expect.stringContaining( - '/preact/test-utils/dist/testUtils.mjs'.replaceAll('/', path.sep), + '@lynx-js/internal-preact/test-utils/dist/testUtils.mjs'.replaceAll( + '/', + path.sep, + ), ), ) expect(config.resolve.alias).toHaveProperty( 'preact/jsx-runtime$', expect.stringContaining( - '/preact/jsx-runtime/dist/jsxRuntime.mjs'.replaceAll('/', path.sep), + '@lynx-js/internal-preact/jsx-runtime/dist/jsxRuntime.mjs'.replaceAll( + '/', + path.sep, + ), ), ) expect(config.resolve.alias).toHaveProperty( 'preact/jsx-dev-runtime$', expect.stringContaining( - '/preact/jsx-runtime/dist/jsxRuntime.mjs'.replaceAll('/', path.sep), + '@lynx-js/internal-preact/jsx-runtime/dist/jsxRuntime.mjs'.replaceAll( + '/', + path.sep, + ), ), ) expect(config.resolve.alias).toHaveProperty( 'preact/compat/client$', expect.stringContaining( - '/preact/compat/client.mjs'.replaceAll('/', path.sep), + '@lynx-js/internal-preact/compat/client.mjs'.replaceAll('/', path.sep), ), ) expect(config.resolve.alias).toHaveProperty( 'preact/compat/server$', expect.stringContaining( - '/preact/compat/server.mjs'.replaceAll('/', path.sep), + '@lynx-js/internal-preact/compat/server.mjs'.replaceAll('/', path.sep), ), ) expect(config.resolve.alias).toHaveProperty( 'preact/compat/jsx-runtime$', expect.stringContaining( - '/preact/compat/jsx-runtime.mjs'.replaceAll('/', path.sep), + '@lynx-js/internal-preact/compat/jsx-runtime.mjs'.replaceAll( + '/', + path.sep, + ), ), ) expect(config.resolve.alias).toHaveProperty( 'preact/compat/jsx-dev-runtime$', expect.stringContaining( - '/preact/compat/jsx-dev-runtime.mjs'.replaceAll('/', path.sep), + '@lynx-js/internal-preact/compat/jsx-dev-runtime.mjs'.replaceAll( + '/', + path.sep, + ), ), ) expect(config.resolve.alias).toHaveProperty( 'preact/compat/scheduler$', expect.stringContaining( - '/preact/compat/scheduler.mjs'.replaceAll('/', path.sep), + '@lynx-js/internal-preact/compat/scheduler.mjs'.replaceAll( + '/', + path.sep, + ), ), ) expect(config.resolve.alias).toHaveProperty( @@ -1691,7 +1721,7 @@ describe('Config', () => { { "name": "lib-preact", "priority": 0, - "test": /node_modules\\[\\\\\\\\/\\]\\(\\.\\*\\?\\[\\\\\\\\/\\]\\)\\?\\(\\?:preact\\|preact\\[\\\\\\\\/\\]compat\\|preact\\[\\\\\\\\/\\]hooks\\|preact\\[\\\\\\\\/\\]jsx-runtime\\)\\[\\\\\\\\/\\]/, + "test": /node_modules\\[\\\\\\\\/\\]\\(\\.\\*\\?\\[\\\\\\\\/\\]\\)\\?\\(\\?:\\(\\?:internal-\\)\\?preact\\|\\(\\?:internal-\\)\\?preact\\[\\\\\\\\/\\]compat\\|\\(\\?:internal-\\)\\?preact\\[\\\\\\\\/\\]hooks\\|\\(\\?:internal-\\)\\?preact\\[\\\\\\\\/\\]jsx-runtime\\)\\[\\\\\\\\/\\]/, } `) }) diff --git a/packages/webpack/react-webpack-plugin/test/cases/basic/bundle-splitting/rspack.config.js b/packages/webpack/react-webpack-plugin/test/cases/basic/bundle-splitting/rspack.config.js index 0d94fb0a2b..5271f9df9e 100644 --- a/packages/webpack/react-webpack-plugin/test/cases/basic/bundle-splitting/rspack.config.js +++ b/packages/webpack/react-webpack-plugin/test/cases/basic/bundle-splitting/rspack.config.js @@ -20,7 +20,7 @@ export default { preact: { name: 'lib-preact', test: - /node_modules[\\/](.*?[\\/])?(?:preact|preact[\\/]compat|preact[\\/]hooks|preact[\\/]jsx-runtime)[\\/]/, + /node_modules[\\/](.*?[\\/])?(?:(?:internal-)?preact|(?:internal-)?preact[\\/]compat|(?:internal-)?preact[\\/]hooks|(?:internal-)?preact[\\/]jsx-runtime)[\\/]/, priority: 0, }, }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 511d855208..aee17c02c1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -547,8 +547,8 @@ importers: packages/react: dependencies: preact: - specifier: npm:@hongzhiyuan/preact@10.28.0-fc4af453 - version: '@hongzhiyuan/preact@10.28.0-fc4af453' + specifier: npm:@lynx-js/internal-preact@10.28.4-ee7bb26 + version: '@lynx-js/internal-preact@10.28.4-ee7bb26' devDependencies: '@lynx-js/types': specifier: 3.7.0 @@ -2960,9 +2960,6 @@ packages: '@floating-ui/utils@0.2.11': resolution: {integrity: sha512-RiB/yIh78pcIxl6lLMG0CgBXAZ2Y0eVHqMPYugu+9U0AeT6YBeiJpf7lbdJNIugFP5SIjwNRgo4DhR1Qxi26Gg==} - '@hongzhiyuan/preact@10.28.0-fc4af453': - resolution: {integrity: sha512-TrM2g079OZN1poroDnU2kQd1gNUB1DMfVoKyz23AE3hZvl9ypRgG2MdgxAJtwT5u3BmYvI4Z0EbdpJTdf428IQ==} - '@hono/node-server@1.19.9': resolution: {integrity: sha512-vHL6w3ecZsky+8P5MD+eFfaGTyCeOHUIFYMGpQGbrBTSmNNoxv0if69rEZ5giu36weC5saFuznL411gRX7bJDw==} engines: {node: '>=18.14.1'} @@ -3175,6 +3172,9 @@ packages: '@leichtgewicht/ip-codec@2.0.5': resolution: {integrity: sha512-Vo+PSpZG2/fmgmiNzYK9qWRh8h/CHrwD0mo1h1DzL4yzHNSfWYujGTYsWGreD000gcgmZ7K4Ys6Tx9TxtsKdDw==} + '@lynx-js/internal-preact@10.28.4-ee7bb26': + resolution: {integrity: sha512-Ym60mgGjj/Xc/5yfludUCUXVCyVACUsNaA7E9Uct2yArsT5nlvp9bflUoLrTNMvApKvbhUBCTx27aNYCquhEYg==} + '@lynx-js/lynx-core@0.1.3': resolution: {integrity: sha512-uWzKKYJUK4Q09ZRZxWSAFINnmZb9piWPbvWF9SkLn+3snBl9u/BJa4ekPRcKWAhBmpbtxWH1x27fxe3Q3p5l3Q==} @@ -11191,8 +11191,6 @@ snapshots: '@floating-ui/utils@0.2.11': {} - '@hongzhiyuan/preact@10.28.0-fc4af453': {} - '@hono/node-server@1.19.9(hono@4.11.7)': dependencies: hono: 4.11.7 @@ -11430,6 +11428,8 @@ snapshots: '@leichtgewicht/ip-codec@2.0.5': {} + '@lynx-js/internal-preact@10.28.4-ee7bb26': {} + '@lynx-js/lynx-core@0.1.3': {} '@lynx-js/preact-devtools@5.0.1': From 4c6bf2e7ac1b9b4e0e318bffcbf8a0453e6e17bb Mon Sep 17 00:00:00 2001 From: Yiming Li Date: Wed, 11 Mar 2026 12:02:07 +0800 Subject: [PATCH 2/2] chore: update changeset --- .changeset/swift-pots-teach.md | 8 ++++++-- packages/rspeedy/plugin-react/package.json | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.changeset/swift-pots-teach.md b/.changeset/swift-pots-teach.md index 71a31ffe3d..e32a13649d 100644 --- a/.changeset/swift-pots-teach.md +++ b/.changeset/swift-pots-teach.md @@ -1,6 +1,10 @@ --- -"@lynx-js/react": patch -"@lynx-js/react-rsbuild-plugin": patch +"@lynx-js/react": minor +"@lynx-js/react-rsbuild-plugin": minor --- +**BREAKING CHANGE**: + Change preact package from `@hongzhiyuan/preact` to `@lynx-js/internal-preact`. + +Upgrade preact from [f7693b72](https://github.com/preactjs/preact/commit/f7693b72ecb4a40c66e6e47f54e2d4edc374c9f0) to [55254ef7](https://github.com/preactjs/preact/commit/55254ef7021e563cc1a86fb816058964a1b6a29a), see diffs at [f7693b72...55254ef7](https://github.com/preactjs/preact/compare/f7693b72ecb4a40c66e6e47f54e2d4edc374c9f0...preactjs:preact:55254ef7021e563cc1a86fb816058964a1b6a29a?expand=1). diff --git a/packages/rspeedy/plugin-react/package.json b/packages/rspeedy/plugin-react/package.json index 0ce33a28fa..753fec3c70 100644 --- a/packages/rspeedy/plugin-react/package.json +++ b/packages/rspeedy/plugin-react/package.json @@ -66,7 +66,7 @@ "typia-rspack-plugin": "2.2.2" }, "peerDependencies": { - "@lynx-js/react": "^0.103.0 || ^0.104.0 || ^0.105.0 || ^0.106.0 || ^0.107.0 || ^0.108.0 || ^0.109.0 || ^0.110.0 || ^0.111.0 || ^0.112.0 || ^0.113.0 || ^0.114.0 || ^0.115.0 || ^0.116.0" + "@lynx-js/react": "^0.103.0 || ^0.104.0 || ^0.105.0 || ^0.106.0 || ^0.107.0 || ^0.108.0 || ^0.109.0 || ^0.110.0 || ^0.111.0 || ^0.112.0 || ^0.113.0 || ^0.114.0 || ^0.115.0 || ^0.116.0 || ^0.117.0" }, "peerDependenciesMeta": { "@lynx-js/react": {