Skip to content

fix: preserve CSS propagation for partial pages imported as components#16415

Open
0xbejaxer wants to merge 6 commits intowithastro:mainfrom
0xbejaxer:fix-16296-partial-css-boundary
Open

fix: preserve CSS propagation for partial pages imported as components#16415
0xbejaxer wants to merge 6 commits intowithastro:mainfrom
0xbejaxer:fix-16296-partial-css-boundary

Conversation

@0xbejaxer
Copy link
Copy Markdown

@0xbejaxer 0xbejaxer commented Apr 20, 2026

Summary

  • refine build CSS boundary detection so top-level pages only stop traversal when they are referenced exclusively by Astro's virtual page module
  • allow partial pages (export const partial = true) that are imported by other pages to keep propagating transitive component CSS in production builds
  • add a regression fixture and build test that verifies transitive CSS from an imported partial is present in index.html output

Validation

  • pnpm -C packages/astro exec astro-scripts test "test/partials-css-boundary.test.ts"
  • Full PR CI matrix is green (build, lint, test, E2E, platform matrix)

Fixes #16296.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 20, 2026

🦋 Changeset detected

Latest commit: f22ad01

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

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

Treat top-level pages as CSS boundaries only when they are referenced exclusively by the virtual page module, so partial pages imported as components continue propagating transitive styles in production builds.

Made-with: Cursor
@0xbejaxer 0xbejaxer force-pushed the fix-16296-partial-css-boundary branch from 9a87942 to 01986de Compare April 20, 2026 18:50
@github-actions github-actions Bot added the pkg: astro Related to the core `astro` package (scope) label Apr 20, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 20, 2026

Merging this PR will not alter performance

✅ 18 untouched benchmarks


Comparing 0xbejaxer:fix-16296-partial-css-boundary (f22ad01) with main (471a4d6)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (1f31d6f) during the generation of this report, so 471a4d6 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Correct the regression fixture path so the partial page can resolve ResultsTable during build on CI.

Made-with: Cursor
Assert that scoped ResultsTable selectors are present in extracted styles instead of matching a specific color token that can be minified differently across environments.

Made-with: Cursor
@0xbejaxer
Copy link
Copy Markdown
Author

Quick update after addressing CI feedback:

  • Fixed fixture import path in the new regression setup
  • Made the assertion minification-safe (checks for scoped selector presence instead of a specific color literal)
  • Kept the core fix unchanged: treat top-level pages as CSS boundaries only when they are imported exclusively by the virtual page module, so imported partial pages continue propagating transitive CSS

All checks are now passing on this branch. Happy to adjust test coverage/assertions further if maintainers prefer a different shape.

@AceCodePt
Copy link
Copy Markdown

Thanks @0xbejaxer !
This is a big help!

0xbejaxer and others added 3 commits April 21, 2026 07:39
Trigger a fresh workflow run for PR withastro#16415 after unrelated flaky E2E failures in actions-blog/cloudflare/hmr tests.

Made-with: Cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: astro Related to the core `astro` package (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Breaking Change: CSS missing in production when using 'export const partial = true' (6.1.0+)

2 participants