-
Notifications
You must be signed in to change notification settings - Fork 116
fix(react/transform): keep webpack runtime variables #1958
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: 0944a34 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
📝 WalkthroughWalkthroughAdds preservation of webpack runtime variables by declaring them in a shared constant and injecting that list into dead-code-elimination (DCE) simplifier configurations; includes tests and a webpack test case to verify the variables are retained. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1).changeset/*.md📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (15)📓 Common learnings📚 Learning: 2025-09-12T09:43:04.847ZApplied to files:
📚 Learning: 2025-09-12T09:43:04.847ZApplied to files:
📚 Learning: 2025-07-22T09:26:16.722ZApplied to files:
📚 Learning: 2025-08-07T04:00:59.645ZApplied to files:
📚 Learning: 2025-07-22T09:23:07.797ZApplied to files:
📚 Learning: 2025-08-19T11:25:36.127ZApplied to files:
📚 Learning: 2025-09-29T06:43:40.182ZApplied to files:
📚 Learning: 2025-08-27T12:42:01.095ZApplied to files:
📚 Learning: 2025-09-23T08:53:56.927ZApplied to files:
📚 Learning: 2025-08-21T08:46:54.494ZApplied to files:
📚 Learning: 2025-09-28T08:46:43.177ZApplied to files:
📚 Learning: 2025-08-12T16:09:32.413ZApplied to files:
📚 Learning: 2025-08-11T05:57:18.212ZApplied to files:
📚 Learning: 2025-09-18T04:43:54.426ZApplied to files:
🔇 Additional comments (1)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. 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 |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
.changeset/blue-shirts-scream.md (1)
1-5: Align changeset wording with actual webpack variable namesTo avoid confusion, it would be better if the description used the exact identifiers you’re preserving:
- Keep webpack runtime variables, like **webpack_public_path**, **webpack_require**.p, etc. + Keep webpack runtime variables like `__webpack_public_path__` and `__webpack_require__.p`, etc.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
.changeset/blue-shirts-scream.md(1 hunks)packages/react/transform/__test__/fixture.spec.js(1 hunks)packages/react/transform/crates/swc_plugins_shared/utils.rs(1 hunks)packages/react/transform/src/lib.rs(3 hunks)packages/react/transform/swc-plugin-reactlynx/src/lib.rs(3 hunks)packages/webpack/react-webpack-plugin/test/cases/webpack-runtime/basic/index.jsx(1 hunks)packages/webpack/react-webpack-plugin/test/cases/webpack-runtime/basic/rspack.config.js(1 hunks)packages/webpack/react-webpack-plugin/test/cases/webpack-runtime/basic/test.config.cjs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
.changeset/*.md
📄 CodeRabbit inference engine (AGENTS.md)
For contributions, generate and commit a Changeset describing your changes
Files:
.changeset/blue-shirts-scream.md
🧠 Learnings (23)
📓 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: 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.
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.
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1454
File: pnpm-workspace.yaml:46-46
Timestamp: 2025-08-07T04:00:59.645Z
Learning: In the lynx-family/lynx-stack repository, the webpack patch (patches/webpack5.101.0.patch) was created to fix issues with webpack5.99.9 but only takes effect on webpack5.100.0 and later versions. The patchedDependencies entry should use "webpack@^5.100.0" to ensure the patch applies to the correct version range.
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1670
File: packages/webpack/css-extract-webpack-plugin/src/loader.ts:244-251
Timestamp: 2025-09-23T08:53:56.927Z
Learning: In webpack CSS extraction plugins, when storing per-module dependencies in a compiler-scoped map like cssModuleId2Deps, the map should not be reset at compilation start because in incremental compilation (watch mode/HMR), only changed files pass through the loader. Unchanged modules need their dependency information to persist between compilations so the plugin can access all modules' dependencies when generating CSS output.
Learnt from: f0rdream
Repo: lynx-family/lynx-stack PR: 1835
File: packages/react/worklet-runtime/src/workletRuntime.ts:52-55
Timestamp: 2025-09-28T08:46:43.177Z
Learning: The legacy worklet path with `_lepusWorkletHash` in `packages/react/worklet-runtime/src/workletRuntime.ts` is preserved for compatibility with MTS (Mini-app Threading Service) that doesn't support Initial Frame Rendering. This path will not be touched in current implementations.
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.
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1238
File: packages/react/runtime/src/debug/component-stack.ts:70-90
Timestamp: 2025-07-18T04:27:18.291Z
Learning: The component-stack.ts file in packages/react/runtime/src/debug/component-stack.ts is a direct fork from https://github.com/preactjs/preact/blob/main/debug/src/component-stack.js. The team prefers to keep it aligned with the upstream Preact version and may contribute improvements back to Preact in the future.
📚 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/react/transform/crates/swc_plugins_shared/utils.rspackages/react/transform/swc-plugin-reactlynx/src/lib.rspackages/webpack/react-webpack-plugin/test/cases/webpack-runtime/basic/test.config.cjspackages/react/transform/__test__/fixture.spec.jspackages/webpack/react-webpack-plugin/test/cases/webpack-runtime/basic/index.jsxpackages/webpack/react-webpack-plugin/test/cases/webpack-runtime/basic/rspack.config.jspackages/react/transform/src/lib.rs
📚 Learning: 2025-09-10T11:42:36.855Z
Learnt from: gaoachao
Repo: lynx-family/lynx-stack PR: 1714
File: packages/react/transform/Cargo.toml:19-19
Timestamp: 2025-09-10T11:42:36.855Z
Learning: In packages/react/transform/Cargo.toml, the crate uses serde derive macros (#[derive(Serialize, Deserialize)]) in multiple files including src/esbuild.rs and src/swc_plugin_extract_str/mod.rs, so the "derive" feature is required when migrating to workspace dependencies.
Applied to files:
packages/react/transform/crates/swc_plugins_shared/utils.rspackages/react/transform/swc-plugin-reactlynx/src/lib.rspackages/react/transform/src/lib.rs
📚 Learning: 2025-11-05T03:26:52.546Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1916
File: packages/react/transform/crates/swc_plugin_snapshot/lib.rs:9-9
Timestamp: 2025-11-05T03:26:52.546Z
Learning: In the lynx-stack repository's swc_core v47 upgrade (PR #1916), the import `use swc_core::atoms as swc_atoms;` is required in files that use the `quote!` macro (e.g., packages/react/transform/crates/swc_plugin_snapshot/lib.rs, swc_plugin_list/lib.rs, swc_plugin_worklet/gen_stmt.rs) even though swc_atoms may not appear explicitly in the source code. This is because the quote! macro generates code that internally references swc_atoms. Removing this import causes compiler error: "failed to resolve: use of unresolved module or unlinked crate `swc_atoms`".
Applied to files:
packages/react/transform/crates/swc_plugins_shared/utils.rspackages/react/transform/swc-plugin-reactlynx/src/lib.rspackages/react/transform/src/lib.rs
📚 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/react/transform/crates/swc_plugins_shared/utils.rspackages/react/transform/swc-plugin-reactlynx/src/lib.rspackages/react/transform/__test__/fixture.spec.jspackages/react/transform/src/lib.rs
📚 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/react/transform/crates/swc_plugins_shared/utils.rspackages/webpack/react-webpack-plugin/test/cases/webpack-runtime/basic/test.config.cjspackages/react/transform/__test__/fixture.spec.js.changeset/blue-shirts-scream.mdpackages/webpack/react-webpack-plugin/test/cases/webpack-runtime/basic/index.jsx
📚 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/react/transform/swc-plugin-reactlynx/src/lib.rspackages/react/transform/__test__/fixture.spec.jspackages/react/transform/src/lib.rs
📚 Learning: 2025-08-21T07:21:51.621Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1562
File: packages/react/transform/src/swc_plugin_snapshot/jsx_helpers.rs:261-283
Timestamp: 2025-08-21T07:21:51.621Z
Learning: In packages/react/transform/src/swc_plugin_snapshot/jsx_helpers.rs, the team prefers to keep the original unreachable! logic for JSXSpreadChild in jsx_is_children_full_dynamic function rather than implementing defensive error handling.
Applied to files:
packages/react/transform/swc-plugin-reactlynx/src/lib.rspackages/react/transform/src/lib.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/react/transform/swc-plugin-reactlynx/src/lib.rspackages/react/transform/__test__/fixture.spec.js.changeset/blue-shirts-scream.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/webpack/react-webpack-plugin/test/cases/webpack-runtime/basic/test.config.cjspackages/react/transform/__test__/fixture.spec.jspackages/webpack/react-webpack-plugin/test/cases/webpack-runtime/basic/index.jsxpackages/webpack/react-webpack-plugin/test/cases/webpack-runtime/basic/rspack.config.js
📚 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/webpack/react-webpack-plugin/test/cases/webpack-runtime/basic/test.config.cjspackages/react/transform/__test__/fixture.spec.jspackages/webpack/react-webpack-plugin/test/cases/webpack-runtime/basic/index.jsxpackages/webpack/react-webpack-plugin/test/cases/webpack-runtime/basic/rspack.config.js
📚 Learning: 2025-09-28T08:46:43.177Z
Learnt from: f0rdream
Repo: lynx-family/lynx-stack PR: 1835
File: packages/react/worklet-runtime/src/workletRuntime.ts:52-55
Timestamp: 2025-09-28T08:46:43.177Z
Learning: The legacy worklet path with `_lepusWorkletHash` in `packages/react/worklet-runtime/src/workletRuntime.ts` is preserved for compatibility with MTS (Mini-app Threading Service) that doesn't support Initial Frame Rendering. This path will not be touched in current implementations.
Applied to files:
packages/react/transform/__test__/fixture.spec.js.changeset/blue-shirts-scream.md
📚 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/react/transform/__test__/fixture.spec.jspackages/webpack/react-webpack-plugin/test/cases/webpack-runtime/basic/index.jsx
📚 Learning: 2025-09-23T08:54:39.966Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1670
File: packages/webpack/css-extract-webpack-plugin/test/hotCases/hot/hot-update-json/dual-thread/__snapshot__/index.css:6-8
Timestamp: 2025-09-23T08:54:39.966Z
Learning: In the lynx-stack CSS extract webpack plugin tests, many test fixture CSS files intentionally use invalid CSS syntax like `color: 'red';` with quoted values. The snapshots correctly reflect this invalid CSS from the source fixtures. To fix CSS validation issues, the source fixture files should be updated first, then snapshots regenerated, rather than manually editing snapshots.
Applied to files:
packages/react/transform/__test__/fixture.spec.js
📚 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/react/transform/__test__/fixture.spec.js.changeset/blue-shirts-scream.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/react/transform/__test__/fixture.spec.js.changeset/blue-shirts-scream.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, 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:
.changeset/blue-shirts-scream.md
📚 Learning: 2025-07-22T09:26:16.722Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1330
File: .changeset/olive-animals-attend.md:1-3
Timestamp: 2025-07-22T09:26:16.722Z
Learning: In the lynx-family/lynx-stack repository, CI checks require changesets when files matching the pattern "src/**" are modified (as configured in .changeset/config.json). For internal changes that don't need meaningful changesets, an empty changeset file is used to satisfy the CI requirement while not generating any release notes.
Applied to files:
.changeset/blue-shirts-scream.md
📚 Learning: 2025-08-07T04:00:59.645Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1454
File: pnpm-workspace.yaml:46-46
Timestamp: 2025-08-07T04:00:59.645Z
Learning: In the lynx-family/lynx-stack repository, the webpack patch (patches/webpack5.101.0.patch) was created to fix issues with webpack5.99.9 but only takes effect on webpack5.100.0 and later versions. The patchedDependencies entry should use "webpack@^5.100.0" to ensure the patch applies to the correct version range.
Applied to files:
.changeset/blue-shirts-scream.md
📚 Learning: 2025-07-22T09:23:07.797Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1330
File: .changeset/olive-animals-attend.md:1-3
Timestamp: 2025-07-22T09:23:07.797Z
Learning: In the lynx-family/lynx-stack repository, changesets are only required for meaningful changes to end-users such as bugfixes and features. Internal/development changes like chores, refactoring, or removing debug info do not need changeset entries.
Applied to files:
.changeset/blue-shirts-scream.md
📚 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:
.changeset/blue-shirts-scream.md
📚 Learning: 2025-09-29T06:43:40.182Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-09-29T06:43:40.182Z
Learning: Applies to .changeset/*.md : For contributions, generate and commit a Changeset describing your changes
Applied to files:
.changeset/blue-shirts-scream.md
📚 Learning: 2025-09-23T08:53:56.927Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1670
File: packages/webpack/css-extract-webpack-plugin/src/loader.ts:244-251
Timestamp: 2025-09-23T08:53:56.927Z
Learning: In webpack CSS extraction plugins, when storing per-module dependencies in a compiler-scoped map like cssModuleId2Deps, the map should not be reset at compilation start because in incremental compilation (watch mode/HMR), only changed files pass through the loader. Unchanged modules need their dependency information to persist between compilations so the plugin can access all modules' dependencies when generating CSS output.
Applied to files:
.changeset/blue-shirts-scream.md
🧬 Code graph analysis (4)
packages/react/transform/crates/swc_plugins_shared/utils.rs (2)
packages/react/transform/src/lib.rs (1)
WEBPACK_VARS(322-322)packages/react/transform/swc-plugin-reactlynx/src/lib.rs (1)
WEBPACK_VARS(121-121)
packages/react/transform/swc-plugin-reactlynx/src/lib.rs (2)
packages/react/transform/crates/swc_plugins_shared/utils.rs (1)
get_relative_path(72-88)packages/react/transform/src/lib.rs (1)
WEBPACK_VARS(322-322)
packages/webpack/react-webpack-plugin/test/cases/webpack-runtime/basic/rspack.config.js (1)
packages/webpack/react-webpack-plugin/test/create-react-config.js (1)
createConfig(79-129)
packages/react/transform/src/lib.rs (1)
packages/react/transform/swc-plugin-reactlynx/src/lib.rs (1)
WEBPACK_VARS(121-121)
⏰ 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). (3)
- GitHub Check: build / Build (Windows)
- GitHub Check: build / Build (Ubuntu)
- GitHub Check: test-rust / Test (Ubuntu)
🔇 Additional comments (7)
packages/react/transform/crates/swc_plugins_shared/utils.rs (1)
90-93: Shared webpack runtime identifier list looks goodExposing
WEBPACK_VARShere is a clean way to centralize the webpack runtime identifiers for all transforms; the types and values look correct.packages/react/transform/__test__/fixture.spec.js (1)
1653-1672: Regression test for webpack runtime preservation is appropriateThis test exercises the transform end-to-end with both preserved (
__webpack_public_path__,__webpack_require__.p) and non-preserved (__webpack_test__) globals and fits the existing snapshot style in this suite.packages/webpack/react-webpack-plugin/test/cases/webpack-runtime/basic/index.jsx (1)
1-11: Webpack runtime test wiring is consistent and targetedThe fixture and assertion pattern cleanly verifies that bundling preserves
__webpack_require__.jand the__webpack_public_path__→__webpack_require__.plink, matching how other webpack runtime tests are structured in this repo.Based on learnings, this matches the existing approach for checking webpack runtime globals.
packages/react/transform/src/lib.rs (1)
63-67: Use ofWEBPACK_VARSin DCE config is coherent with the intended behaviorDeriving a
top_retainvector fromWEBPACK_VARSand threading it intosimplify::dce::Configfor bothsimplify_pass_1and the mainsimplify_passkeeps the NAPI transform path aligned with the shared webpack runtime allowlist, and the allocation/cloning pattern is reasonable for this hot path.Please double-check against the
swc_coreversion in this workspace thatdce.top_retainstill expects aVec<Atom>(or equivalent) and that its semantics match what you need for retaining__webpack_require__and__webpack_public_path__at the top level.Also applies to: 322-323, 328-332, 456-459
packages/react/transform/swc-plugin-reactlynx/src/lib.rs (1)
33-37: Plugin transform now shares the webpack retention list with the NAPI pathMirroring
top_retaininitialization fromWEBPACK_VARSinto both simplify passes here keeps the SWC plugin behavior in lockstep withpackages/react/transform/src/lib.rs, so webpack runtime globals are treated consistently regardless of entry path.As with the NAPI transform, please confirm against the current
swc_coredocs thatsimplify::dce::Config::top_retainbehaves as expected for these globals in the plugin environment.Also applies to: 121-122, 127-131, 233-236
packages/webpack/react-webpack-plugin/test/cases/webpack-runtime/basic/test.config.cjs (1)
1-7: Test case config matches expected bundle outputsThe exported
bundlePathentries align with thecreateConfigsetup and provide the necessary artifacts for this webpack-runtime case.packages/webpack/react-webpack-plugin/test/cases/webpack-runtime/basic/rspack.config.js (1)
1-7: Rspack test configuration correctly reuses shared React configImporting
createConfigfrom the shared helper and spreading it into a context-scoped default export is a straightforward way to hook this case into the existing webpack test harness.
CodSpeed Performance ReportMerging #1958 will not alter performanceComparing Summary
Footnotes
|
Web Explorer#6340 Bundle Size — 377.5KiB (0%).0944a34(current) vs 55cb796 main#6337(baseline) Bundle metrics
Bundle size by type
|
| Current #6340 |
Baseline #6337 |
|
|---|---|---|
243.18KiB |
243.18KiB |
|
101.94KiB |
101.94KiB |
|
32.38KiB |
32.38KiB |
Bundle analysis report Branch p/hujing/transfrom-shaking Project dashboard
Generated by RelativeCI Documentation Report issue
colinaaa
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM
Co-authored-by: Qingyu Wang <[email protected]> Signed-off-by: HuJean <[email protected]>
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/[email protected] ### Minor Changes - **BREAKING CHANGE**: Delay the `createSnapshot` operation to `Snapshot` constructor to speed up IFR. ([#1899](#1899)) This change refactors how snapshots are created and registered: - Removed the `entryUniqID` function - Snapshots are now lazily created via `snapshotCreatorMap` instead of eagerly at bundle load time - Snapshot IDs are generated at compile time and only prefixed with `${globDynamicComponentEntry}:` for standalone lazy bundles **⚠️ Lazy Bundle Compatibility:** - **Backward compatibility (new runtime → old lazy bundles)**: ✅ **Supported**. Old lazy bundles will work with the new runtime. - **Forward compatibility (old runtime → new lazy bundles)**: ❌ **NOT Supported**. Lower version consumers **will not be able to load lazy bundles produced by this version** due to the changed snapshot creation mechanism. **Migration guidance**: If you are using lazy bundles, ensure all consumers are upgraded to this version or later **before** deploying lazy bundles built with this version. For monorepo setups, coordinate the upgrade across all consuming applications. ### Patch Changes - Preserve assignments to webpack runtime variables like `__webpack_public_path__`, `__webpack_require__.p`, etc. ([#1958](#1958)) - Fixed blank screen issues with nested lists. Lazily created nested lists were being flushed but not properly recorded, causing rendering failures. ([#1963](#1963)) - fix: export `createRef` and `useRef` from `@lynx-js/react/legacy-react-runtime` ([#1953](#1953)) ## @lynx-js/[email protected] ### Minor Changes - **BREAKING CHANGE**: Require `@lynx-js/rspeedy` 0.12.0. ([#1951](#1951)) ### Patch Changes - Support Yarn Plug'n'Play. ([#1964](#1964)) - Updated dependencies \[[`738d44d`](738d44d), [`5bbb439`](5bbb439), [`3692a16`](3692a16), [`d2e290b`](d2e290b), [`738d44d`](738d44d)]: - @lynx-js/[email protected] - @lynx-js/[email protected] - @lynx-js/[email protected] - @lynx-js/[email protected] - @lynx-js/[email protected] - @lynx-js/[email protected] ## @lynx-js/[email protected] ### Minor Changes - **BREAKING CHANGE**: Use resolver from Rspack. ([#1964](#1964)) The `createLazyResolver` now requires an `rspack` parameter: ```diff - function createLazyResolver(directory: string, conditionNames: string[]): (request: string) => Promise<string>; + function createLazyResolver(rspack: rspack, directory: string, conditionNames: string[]): (request: string) => Promise<string>; ``` ### Patch Changes - Support Yarn Plug'n'Play. ([#1964](#1964)) ## @lynx-js/[email protected] ### Minor Changes - feat: new flex:val impl ([#1979](#1979)) ### Patch Changes - Updated dependencies \[[`40c3a1a`](40c3a1a), [`46bd5ee`](46bd5ee)]: - @lynx-js/[email protected] - @lynx-js/[email protected] - @lynx-js/[email protected] - @lynx-js/[email protected] ## @lynx-js/[email protected] ### Minor Changes - feat: new flex:val impl ([#1979](#1979)) ### Patch Changes - fix: x-input display should add !important to avoid override ([#1960](#1960)) - Updated dependencies \[]: - @lynx-js/[email protected] ## @lynx-js/[email protected] ### Patch Changes - Bump Rsbuild v1.6.9 with Rspack v1.6.5. ([#1967](#1967)) - Updated dependencies \[]: - @lynx-js/[email protected] ## [email protected] ### Patch Changes - Bump `@rsbuild/plugin-type-check` v1.3.1. ([#1964](#1964)) ## @lynx-js/[email protected] ### Patch Changes - Add `@lynx-js/lynx-bundle-rslib-config` for bundling Lynx bundle with [Rslib](https://rslib.rs/): ([#1943](#1943)) ```js // rslib.config.js import { defineExternalBundleRslibConfig } from "@lynx-js/lynx-bundle-rslib-config"; export default defineExternalBundleRslibConfig({ id: "utils-lib", source: { entry: { utils: "./src/utils.ts", }, }, }); ``` ## @lynx-js/[email protected] ### Patch Changes - Updated dependencies \[]: - @lynx-js/[email protected] ## @lynx-js/[email protected] ### Patch Changes - chore: update web-elements version of web-explorer ([#1962](#1962)) ## @lynx-js/[email protected] ### Patch Changes - fix: capture and bind event listener should be trigger correctly ([#1972](#1972)) - fix: the l-p-comp-uid of page should be '1' ([#1970](#1970)) - Updated dependencies \[]: - @lynx-js/[email protected] ## @lynx-js/[email protected] ### Patch Changes - Updated dependencies \[[`40c3a1a`](40c3a1a), [`46bd5ee`](46bd5ee)]: - @lynx-js/[email protected] - @lynx-js/[email protected] - @lynx-js/[email protected] ## @lynx-js/[email protected] ### Patch Changes - Set main thread JS basename to `lepusCode.filename` in tasm encode data. It will ensure a filename is reported on MTS error without devtools enabled. ([#1949](#1949)) ## @lynx-js/[email protected] ### Patch Changes - Set main thread JS basename to `lepusCode.filename` in tasm encode data. It will ensure a filename is reported on MTS error without devtools enabled. ([#1949](#1949)) - Upgrade `@lynx-js/tasm` to `0.0.20`. ([#1943](#1943)) - refactor: move web style info generation to the encode phase ([#1975](#1975)) ## [email protected] ## @lynx-js/[email protected] ## @lynx-js/[email protected] ## @lynx-js/[email protected] ## @lynx-js/[email protected] Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Closed #1957
Summary by CodeRabbit
Bug Fixes
Tests
Chores
✏️ Tip: You can customize this high-level summary in your review settings.
Checklist