fix(core): stop Comments/CommentForm CSS from leaking into every emdash/ui page#2215
Draft
marcusbellamyshaw-cell wants to merge 1 commit into
Draft
Conversation
…sh/ui page Comments.astro and CommentForm.astro shared a barrel (components/index.ts) with PortableText and the block-type components. Astro bundles the `<style>` block of any component reachable in a barrel's static import graph into the page's CSS chunk, regardless of which named export is actually used, so any page importing PortableText from `emdash/ui` also pulled in comments' CSS. Move Comments/CommentForm into their own module, re-exported from `emdash/ui` on a separate import path so the two no longer share a static import graph. Public API (`emdash/ui`'s exports) is unchanged. Fixes emdash-cms#2039.
🦋 Changeset detectedLatest commit: 28cdcab The changes in this PR will be included in the next version bump. This PR includes changesets to release 17 packages
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 |
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/auth-atproto
@emdash-cms/blocks
@emdash-cms/cloudflare
@emdash-cms/contentful-to-portable-text
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/plugin-cli
@emdash-cms/plugin-types
@emdash-cms/registry-client
@emdash-cms/registry-lexicons
@emdash-cms/registry-verification
@emdash-cms/sandbox-workerd
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-field-kit
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
emdash/ui's barrel (src/components/index.ts) re-exportedComments/CommentFormalongsidePortableTextand the block-type components. Astro's CSS scanner bundles the<style>block of every component reachable in a barrel's static import graph into the page's CSS chunk, regardless of which named export a page actually imports — so any site doingimport { PortableText } from "emdash/ui"got Comments/CommentForm's CSS (~13 KB uncompressed) bundled into a shared, render-blocking chunk on every page, even pages that never render comments.Same class of bug already fixed for the admin stylesheet in #1281.
Fix: move
Comments/CommentForminto their own module (components/comments.ts), re-exported fromemdash/uion a separate import statement so the two no longer share a static import graph.emdash/ui's public export surface is unchanged —import { PortableText, Comments, CommentForm } from "emdash/ui"still works exactly as before; only pages that import solelyPortableText/blocks stop pulling in comments' CSS.No full production-build harness exists in this test suite to assert on emitted CSS chunk contents directly (same situation as #938's fix), so the regression test asserts the underlying structural condition instead: the PortableText/blocks barrel no longer references
Comments.astro/CommentForm.astro, andemdash/uistill exports both via a distinct module.Closes #2039
Type of change
Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (or targeted tests for my change)pnpm formathas been runAI-generated code disclosure