Skip to content

feat(template-webpack-plugin): remove initialize compiler hooks#1898

Merged
colinaaa merged 1 commit intolynx-family:mainfrom
luhc228:feat/remove-compiler-initialize-hooks
Oct 29, 2025
Merged

feat(template-webpack-plugin): remove initialize compiler hooks#1898
colinaaa merged 1 commit intolynx-family:mainfrom
luhc228:feat/remove-compiler-initialize-hooks

Conversation

@luhc228
Copy link
Copy Markdown
Collaborator

@luhc228 luhc228 commented Oct 28, 2025

  1. compiler.hooks.initialize will not be called in child compilers, it is only called once in main compiler.
// the example of using `LynxTemplatePlugin` in child compiler
import { LynxTemplatePlugin } from '@lynx-js/template-webpack-plugin'

loaderContext._compilation.createChildCompiler(
  'child-compiler-name',
  {},
  [
     new LynxTemplatePlugin({ /* options */ })
  ]
)
  1. Maybe it is not necessary to wrap in compiler.hooks.initialize.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed an issue where the webpack template plugin was not properly initializing in child compiler scenarios.
  • Chores

    • Added patch-level changeset for @lynx-js/template-webpack-plugin.

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

@luhc228 luhc228 requested a review from colinaaa as a code owner October 28, 2025 02:01
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Oct 28, 2025

🦋 Changeset detected

Latest commit: 3baafe4

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

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 Oct 28, 2025

📝 Walkthrough

Walkthrough

Move entryName-to-filename generation and output handling from compiler.hooks.initialize to the LynxTemplatePluginImpl constructor. The initialization hook is not invoked in child compilers, so this relocation ensures the logic executes during plugin construction.

Changes

Cohort / File(s) Summary
Initialization Refactoring
.changeset/thin-webs-enjoy.md, packages/webpack/template-webpack-plugin/src/LynxTemplatePlugin.ts
Moves entryName-to-filename generation and per-output handling from compiler.hooks.initialize to constructor; removes unused initialize hook due to lack of invocation in child compilers; maintains existing logic with updated timing.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Verify that moving logic from initialize hook to constructor doesn't affect initialization order or side effects
  • Confirm the relocation works correctly in both parent and child compiler contexts
  • Validate that per-output filename processing still executes as expected

Suggested labels

platform:Web

Suggested reviewers

  • colinaaa

Poem

A hook that never fires in the child's domain,
Now springs to life within the constructor's frame,
Filenames computed early, outputs arranged with care,
The initialization dance finds its proper lair! 🐰✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title "feat(template-webpack-plugin): remove initialize compiler hooks" accurately reflects the primary change in the pull request. The raw_summary confirms that the changeset removes compiler.hooks.initialize because it is not invoked in child compilers, and the LynxTemplatePlugin.ts file demonstrates the refactoring that moves plugin initialization logic from the initialize hook to the constructor. The title is concise, specific, and clearly conveys the main modification without ambiguity or unnecessary elements, directly matching the stated PR objectives.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 Oct 28, 2025

Codecov Report

❌ Patch coverage is 82.85714% with 6 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
.../template-webpack-plugin/src/LynxTemplatePlugin.ts 82.85% 6 Missing ⚠️

📢 Thoughts on this report? Let us know!

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Oct 28, 2025

CodSpeed Performance Report

Merging #1898 will degrade performances by 6.22%

Comparing luhc228:feat/remove-compiler-initialize-hooks (3baafe4) with main (4296178)

Summary

❌ 2 regressions
✅ 51 untouched
⏩ 3 skipped1

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

Benchmarks breakdown

Benchmark BASE HEAD Change
basic-performance-image-100 9.8 ms 10.3 ms -5.17%
basic-performance-small-css 7.2 ms 7.6 ms -6.22%

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 Oct 28, 2025

Web Explorer

#5986 Bundle Size — 364.68KiB (0%).

3baafe4(current) vs 4296178 main#5970(baseline)

Bundle metrics  Change 1 change
                 Current
#5986
     Baseline
#5970
No change  Initial JS 144.63KiB 144.63KiB
No change  Initial CSS 32.11KiB 32.11KiB
No change  Cache Invalidation 0% 0%
No change  Chunks 8 8
No change  Assets 8 8
Change  Modules 220(+0.46%) 219
No change  Duplicate Modules 16 16
No change  Duplicate Code 3.23% 3.23%
No change  Packages 4 4
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#5986
     Baseline
#5970
No change  JS 238.77KiB 238.77KiB
No change  Other 93.8KiB 93.8KiB
No change  CSS 32.11KiB 32.11KiB

Bundle analysis reportBranch luhc228:feat/remove-compiler-ini...Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci bot commented Oct 28, 2025

React Example

#5990 Bundle Size — 237.5KiB (0%).

3baafe4(current) vs 4296178 main#5974(baseline)

Bundle metrics  no changes
                 Current
#5990
     Baseline
#5974
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
No change  Cache Invalidation 0% 0%
No change  Chunks 0 0
No change  Assets 4 4
No change  Modules 165 165
No change  Duplicate Modules 67 67
No change  Duplicate Code 46.77% 46.77%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#5990
     Baseline
#5974
No change  IMG 145.76KiB 145.76KiB
No change  Other 91.74KiB 91.74KiB

Bundle analysis reportBranch luhc228:feat/remove-compiler-ini...Project dashboard


Generated by RelativeCIDocumentationReport issue

@colinaaa colinaaa merged commit 96545dd into lynx-family:main Oct 29, 2025
86 of 89 checks passed
colinaaa pushed a commit that referenced this pull request Nov 3, 2025
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/rspeedy@0.11.8

### Patch Changes

- feat: support web preview in rspeedy dev
([#1891](#1891))

    -   print URLs with labels

-   Updated dependencies \[]:
    -   @lynx-js/web-rsbuild-server-middleware@0.18.2

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

### Patch Changes

- Updated dependencies
\[[`96545dd`](96545dd)]:
    -   @lynx-js/template-webpack-plugin@0.9.1
    -   @lynx-js/css-extract-webpack-plugin@0.6.4
    -   @lynx-js/react-webpack-plugin@0.7.1
    -   @lynx-js/react-alias-rsbuild-plugin@0.11.3

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

### Patch Changes

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

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

### Patch Changes

- feat: builtinTagTransformMap add `'input': 'x-input'`
([#1907](#1907))

-   Updated dependencies \[]:
    -   @lynx-js/web-constants@0.18.2
    -   @lynx-js/web-mainthread-apis@0.18.2
    -   @lynx-js/web-worker-rpc@0.18.2
    -   @lynx-js/web-worker-runtime@0.18.2

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

### Patch Changes

- feat: builtinTagTransformMap add `'input': 'x-input'`
([#1907](#1907))

## @lynx-js/web-explorer@0.0.11

### Patch Changes

- feat: builtinTagTransformMap add `'input': 'x-input'`
([#1907](#1907))

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

### Patch Changes

-   Updated dependencies \[]:
    -   @lynx-js/web-constants@0.18.2
    -   @lynx-js/web-style-transformer@0.18.2

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

### Patch Changes

-   Updated dependencies \[]:
    -   @lynx-js/web-constants@0.18.2
    -   @lynx-js/web-mainthread-apis@0.18.2
    -   @lynx-js/web-worker-rpc@0.18.2

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

### Patch Changes

- Remove `compiler.hooks.initialize` as [it's not called in child
compilers](https://github.com/web-infra-dev/rspack/blob/aa4ad886b900770787ecddd625d3e24a51b6b99c/packages/rspack/src/rspack.ts#L78).
([#1898](#1898))

## create-rspeedy@0.11.8



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



## upgrade-rspeedy@0.11.8



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



## @lynx-js/web-style-transformer@0.18.2



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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants