perf: lazy loading webpack-merge dependency#6668
Conversation
✅ Deploy Preview for rsbuild ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull request overview
This PR implements lazy loading for the webpack-merge dependency to improve startup performance and reduce the main bundle size. The change defers loading webpack-merge until it's actually needed, resulting in a ~37kB reduction in bundle size (from 508.7 kB to 471.8 kB).
Key changes:
- Converted
mergeConfigfrom a direct import to a lazy-loaded function wrapper - Added
webpack-mergeto the compiled packages type definitions - Configured
webpack-mergefor prebundling
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/core/src/provider/rspackConfig.ts | Replaced direct merge import with lazy loading via requireCompiledPackage in the mergeConfig utility function |
| packages/core/src/helpers/vendors.ts | Added webpack-merge type definition to the CompiledPackages interface |
| packages/core/prebundle.config.ts | Added webpack-merge to the list of dependencies to be prebundled |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Summary
Lazy loading webpack-merge dependency to reduce main bundle size and make startup faster.
Before
File (esm_index) Size dist/index.js 0.21 kB dist/0~range-parser.js 2.3 kB dist/rslib-runtime.js 2.3 kB dist/0~open.js 18.4 kB dist/131.js 485.4 kB Total: 508.7 kBAfter
File (esm_index) Size dist/index.js 0.21 kB dist/rslib-runtime.js 2.3 kB dist/0~range-parser.js 2.3 kB dist/0~open.js 18.4 kB dist/131.js 448.5 kB Total: 471.8 kBChecklist