Skip to content

fix(core): stop Comments/CommentForm CSS from leaking into every emdash/ui page#2215

Draft
marcusbellamyshaw-cell wants to merge 1 commit into
emdash-cms:mainfrom
Emdash-Bug-Testing:fix/2039-comments-css-barrel-isolation
Draft

fix(core): stop Comments/CommentForm CSS from leaking into every emdash/ui page#2215
marcusbellamyshaw-cell wants to merge 1 commit into
emdash-cms:mainfrom
Emdash-Bug-Testing:fix/2039-comments-css-barrel-isolation

Conversation

@marcusbellamyshaw-cell

Copy link
Copy Markdown
Contributor

What does this PR do?

emdash/ui's barrel (src/components/index.ts) re-exported Comments/CommentForm alongside PortableText and 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 doing import { 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/CommentForm into their own module (components/comments.ts), re-exported from emdash/ui on 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 solely PortableText/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, and emdash/ui still exports both via a distinct module.

Closes #2039

Type of change

  • Bug fix

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm test passes (or targeted tests for my change)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • User-visible strings in the admin UI are wrapped for translation (if applicable) — n/a, no admin UI strings changed
  • I have added a changeset (if this PR changes a published package)
  • New features link to an approved Discussion — n/a, bug fix

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: Claude Sonnet 5

…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-bot

changeset-bot Bot commented Jul 23, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 28cdcab

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

This PR includes changesets to release 17 packages
Name Type
emdash Patch
@emdash-cms/cloudflare Patch
@emdash-cms/sandbox-workerd Patch
@emdash-cms/plugin-mcp-smoke Patch
@emdash-cms/fixture-perf-site Patch
@emdash-cms/perf-demo-site Patch
@emdash-cms/cache-demo-site Patch
@emdash-cms/do-demo-site Patch
@emdash-cms/do-solo-demo-site Patch
@emdash-cms/admin Patch
@emdash-cms/auth Patch
@emdash-cms/blocks Patch
@emdash-cms/gutenberg-to-portable-text Patch
@emdash-cms/x402 Patch
create-emdash Patch
@emdash-cms/auth-atproto Patch
@emdash-cms/plugin-embeds 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

@pkg-pr-new

pkg-pr-new Bot commented Jul 23, 2026

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/@emdash-cms/admin@2215

@emdash-cms/auth

npm i https://pkg.pr.new/@emdash-cms/auth@2215

@emdash-cms/auth-atproto

npm i https://pkg.pr.new/@emdash-cms/auth-atproto@2215

@emdash-cms/blocks

npm i https://pkg.pr.new/@emdash-cms/blocks@2215

@emdash-cms/cloudflare

npm i https://pkg.pr.new/@emdash-cms/cloudflare@2215

@emdash-cms/contentful-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/contentful-to-portable-text@2215

emdash

npm i https://pkg.pr.new/emdash@2215

create-emdash

npm i https://pkg.pr.new/create-emdash@2215

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/gutenberg-to-portable-text@2215

@emdash-cms/plugin-cli

npm i https://pkg.pr.new/@emdash-cms/plugin-cli@2215

@emdash-cms/plugin-types

npm i https://pkg.pr.new/@emdash-cms/plugin-types@2215

@emdash-cms/registry-client

npm i https://pkg.pr.new/@emdash-cms/registry-client@2215

@emdash-cms/registry-lexicons

npm i https://pkg.pr.new/@emdash-cms/registry-lexicons@2215

@emdash-cms/registry-verification

npm i https://pkg.pr.new/@emdash-cms/registry-verification@2215

@emdash-cms/sandbox-workerd

npm i https://pkg.pr.new/@emdash-cms/sandbox-workerd@2215

@emdash-cms/x402

npm i https://pkg.pr.new/@emdash-cms/x402@2215

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-moderation@2215

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/@emdash-cms/plugin-atproto@2215

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/@emdash-cms/plugin-audit-log@2215

@emdash-cms/plugin-color

npm i https://pkg.pr.new/@emdash-cms/plugin-color@2215

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/@emdash-cms/plugin-embeds@2215

@emdash-cms/plugin-field-kit

npm i https://pkg.pr.new/@emdash-cms/plugin-field-kit@2215

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/@emdash-cms/plugin-forms@2215

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/@emdash-cms/plugin-webhook-notifier@2215

commit: 28cdcab

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.

Comments/CommentForm CSS bleeds into all pages via emdash/ui barrel import

1 participant