Skip to content

feat: move cssChunksToMap implementation to @lynx-js/css-serializer#2269

Merged
upupming merged 1 commit intomainfrom
feat/cssChunksToMap
Feb 25, 2026
Merged

feat: move cssChunksToMap implementation to @lynx-js/css-serializer#2269
upupming merged 1 commit intomainfrom
feat/cssChunksToMap

Conversation

@upupming
Copy link
Copy Markdown
Collaborator

@upupming upupming commented Feb 24, 2026

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Patched @lynx-js/template-webpack-plugin and @lynx-js/css-serializer.
  • New Features

    • Exposed CSS namespace directly from @lynx-js/css-serializer.
    • Added CSSPlugins export with parserPlugins property.
    • Made cssChunksToMap available as a public export from @lynx-js/css-serializer.
  • Chores

    • Updated test imports and configuration for improved module resolution.

In #2143, we need to use cssChunksToMap in @lynx-js/lynx-bundle-rslib-config package.

To avoid repeating ourselves, we extract the cssChunksToMap API from @lynx-js/template-webpack-plugin to @lynx-js/css-serializer.

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

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Feb 24, 2026

🦋 Changeset detected

Latest commit: 7075e4a

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

This PR includes changesets to release 5 packages
Name Type
@lynx-js/template-webpack-plugin Patch
@lynx-js/css-serializer Patch
@lynx-js/react-rsbuild-plugin Patch
@lynx-js/web-core-wasm 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 Feb 24, 2026

📝 Walkthrough

Walkthrough

Relocates the cssChunksToMap implementation from @lynx-js/template-webpack-plugin to @lynx-js/css-serializer package, reorganizes internal imports and exports across both packages, and updates the public API surface to expose CSS utilities through the css-serializer namespace.

Changes

Cohort / File(s) Summary
Changeset & css-serializer package setup
.changeset/wet-rockets-taste.md, packages/tools/css-serializer/src/css/ast.ts, packages/tools/css-serializer/src/css/cssChunksToMap.ts
Declares patch version bumps for css-serializer and template-webpack-plugin; updates internal module imports to use local index files instead of external package references.
css-serializer public API
packages/tools/css-serializer/src/css/index.ts, packages/tools/css-serializer/src/index.ts, packages/tools/css-serializer/test/css.test.ts, packages/tools/css-serializer/vitest.config.ts
Adds new cssChunksToMap export, removes parserPlugins alias, and extends test configuration; test imports updated to reference new api surface.
template-webpack-plugin API declaration
packages/webpack/template-webpack-plugin/etc/template-webpack-plugin.api.md
Major API restructuring: consolidates granular CSS exports into single CSS namespace export, introduces CSSPlugins as concrete constant, updates method signatures to reference CSS.Plugin[] and CSS.LynxStyleNode[], removes inline CSS namespace redeclaration.
template-webpack-plugin imports & exports
packages/webpack/template-webpack-plugin/src/index.ts, packages/webpack/template-webpack-plugin/src/LynxTemplatePlugin.ts, packages/webpack/template-webpack-plugin/src/WebEncodePlugin.ts, packages/webpack/template-webpack-plugin/src/css/index.ts, packages/webpack/template-webpack-plugin/src/web/genStyleInfo.ts
Reorganizes imports to source CSS types and utilities from @lynx-js/css-serializer; removes 15 lines of old local re-exports from css/index.ts; replaces wildcard exports with concrete CSSPlugins constant in main index.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

platform:Web

Suggested reviewers

  • colinaaa
  • luhc228

Poem

🐰 A webpack refactor with grace and care,
CSS chunks now serialize with flair,
From template-plugin they take their flight,
To css-serializer, shining bright! ✨
Imports reorganized, APIs align—
Clean abstractions, oh how divine! 🌿

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately summarizes the main objective of the changeset: relocating the cssChunksToMap implementation from the template-webpack-plugin to the css-serializer package.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/cssChunksToMap

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 Feb 24, 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!

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

🧹 Nitpick comments (1)
packages/webpack/template-webpack-plugin/src/index.ts (1)

11-12: Consolidate the two imports from @lynx-js/css-serializer into one.

Plugins is already available as CSS.Plugins from the namespace import, making the separate named import redundant.

♻️ Proposed refactor
-import { Plugins } from '@lynx-js/css-serializer';
 import * as CSS from '@lynx-js/css-serializer';

Then update the usage below:

 export const CSSPlugins: {
-  parserPlugins: typeof Plugins;
+  parserPlugins: typeof CSS.Plugins;
 } = {
-  parserPlugins: Plugins,
+  parserPlugins: CSS.Plugins,
 };
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/webpack/template-webpack-plugin/src/index.ts` around lines 11 - 12,
Remove the redundant named import and use the namespace import only: replace the
two imports with a single namespace import (keep import * as CSS from
'@lynx-js/css-serializer') and update any references to the named symbol Plugins
to use CSS.Plugins (search for usages of Plugins in this module and prefix them
with CSS.). Ensure no other named imports from '@lynx-js/css-serializer' remain.
🤖 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/webpack/template-webpack-plugin/src/index.ts`:
- Around line 23-27: The exported constant CSSPlugins is missing a JSDoc release
tag which triggers API Extractor; add a JSDoc block immediately above the
CSSPlugins declaration (referencing CSSPlugins and Plugins) that includes a
short description and the `@public` release tag so the symbol is explicitly public
in the API surface.

---

Nitpick comments:
In `@packages/webpack/template-webpack-plugin/src/index.ts`:
- Around line 11-12: Remove the redundant named import and use the namespace
import only: replace the two imports with a single namespace import (keep import
* as CSS from '@lynx-js/css-serializer') and update any references to the named
symbol Plugins to use CSS.Plugins (search for usages of Plugins in this module
and prefix them with CSS.). Ensure no other named imports from
'@lynx-js/css-serializer' remain.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 98b2504 and 7075e4a.

📒 Files selected for processing (14)
  • .changeset/wet-rockets-taste.md
  • packages/tools/css-serializer/src/css/ast.ts
  • packages/tools/css-serializer/src/css/cssChunksToMap.ts
  • packages/tools/css-serializer/src/css/debundle.ts
  • packages/tools/css-serializer/src/css/index.ts
  • packages/tools/css-serializer/src/index.ts
  • packages/tools/css-serializer/test/css.test.ts
  • packages/tools/css-serializer/vitest.config.ts
  • packages/webpack/template-webpack-plugin/etc/template-webpack-plugin.api.md
  • packages/webpack/template-webpack-plugin/src/LynxTemplatePlugin.ts
  • packages/webpack/template-webpack-plugin/src/WebEncodePlugin.ts
  • packages/webpack/template-webpack-plugin/src/css/index.ts
  • packages/webpack/template-webpack-plugin/src/index.ts
  • packages/webpack/template-webpack-plugin/src/web/genStyleInfo.ts
💤 Files with no reviewable changes (1)
  • packages/webpack/template-webpack-plugin/src/css/index.ts

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Feb 24, 2026

Merging this PR will not alter performance

✅ 63 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing feat/cssChunksToMap (7075e4a) with main (98b2504)

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 Feb 24, 2026

Web Explorer

#7777 Bundle Size — 383.74KiB (0%).

7075e4a(current) vs 98b2504 main#7766(baseline)

Bundle metrics  no changes
                 Current
#7777
     Baseline
#7766
No change  Initial JS 154.88KiB 154.88KiB
No change  Initial CSS 35.06KiB 35.06KiB
No change  Cache Invalidation 0% 0%
No change  Chunks 8 8
No change  Assets 8 8
No change  Modules 238 238
No change  Duplicate Modules 16 16
No change  Duplicate Code 2.99% 2.99%
No change  Packages 4 4
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#7777
     Baseline
#7766
No change  JS 252.83KiB 252.83KiB
No change  Other 95.85KiB 95.85KiB
No change  CSS 35.06KiB 35.06KiB

Bundle analysis reportBranch feat/cssChunksToMapProject dashboard


Generated by RelativeCIDocumentationReport issue

Copy link
Copy Markdown
Collaborator

@luhc228 luhc228 left a comment

Choose a reason for hiding this comment

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

@upupming upupming merged commit 9033e2d into main Feb 25, 2026
48 checks passed
@upupming upupming deleted the feat/cssChunksToMap branch February 25, 2026 09:03
colinaaa pushed a commit that referenced this pull request Mar 2, 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.116.4

### Patch Changes

- Support `ReactLynx::hooks::setState` trace for function components.
([#2198](#2198))

- fix: properly cleanup `__DestroyLifetime` listeners and listCallbacks
in `snapshotDestroyList`.
([#2224](#2224))

## @lynx-js/qrcode-rsbuild-plugin@0.4.6

### Patch Changes

- Print all entries with all schema URLs in non-TTY environments instead
of only showing the first entry's QR code.
([#2227](#2227))

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

### Patch Changes

- Add alias for `use-sync-external-store/with-selector.js` and
`use-sync-external-store/shim/with-selector.js` pointing to
@lynx-js/use-sync-external-store.
([#2200](#2200))

- Updated dependencies
\[[`9033e2d`](9033e2d)]:
    -   @lynx-js/template-webpack-plugin@0.10.4
    -   @lynx-js/react-alias-rsbuild-plugin@0.12.9
    -   @lynx-js/use-sync-external-store@1.5.0
    -   @lynx-js/react-refresh-webpack-plugin@0.3.4
    -   @lynx-js/react-webpack-plugin@0.7.4
    -   @lynx-js/css-extract-webpack-plugin@0.7.0

## @lynx-js/css-serializer@0.1.4

### Patch Changes

- Move `cssChunksToMap` implementation from
`@lynx-js/template-webpack-plugin` to `@lynx-js/css-serializer` for
future reuse.
([#2269](#2269))

## @lynx-js/web-core-wasm@0.0.4

### Patch Changes

- Refactor web element templates and server-side rendering logic
([#2205](#2205))

- Updated dependencies
\[[`94e5779`](94e5779),
[`9033e2d`](9033e2d)]:
    -   @lynx-js/web-elements@0.11.3
    -   @lynx-js/css-serializer@0.1.4

## @lynx-js/web-elements@0.11.3

### Patch Changes

- fix: firefox 147+ layout issue
([#2205](#2205))

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

### Patch Changes

- Move `cssChunksToMap` implementation from
`@lynx-js/template-webpack-plugin` to `@lynx-js/css-serializer` for
future reuse.
([#2269](#2269))

- Updated dependencies
\[[`9033e2d`](9033e2d)]:
    -   @lynx-js/css-serializer@0.1.4

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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants