Skip to content

fix: re-export semantic-ui components through CSS wrapper modules#608

Open
LautaroPetaccio wants to merge 1 commit into
masterfrom
fix/css-tree-shaking-exports
Open

fix: re-export semantic-ui components through CSS wrapper modules#608
LautaroPetaccio wants to merge 1 commit into
masterfrom
fix/css-tree-shaking-exports

Conversation

@LautaroPetaccio

Copy link
Copy Markdown
Contributor

Summary

  • Re-export semantic-ui-react components that have CSS overrides (Card, Button, Modal, etc.) through their wrapper modules in src/components/ instead of directly from semantic-ui-react
  • Add explicit Loader export from its wrapper module
  • Replace the wildcard export * from 'semantic-ui-react' with explicit named exports for components without CSS overrides

Problem

Components like Card, Button, Modal, etc. have wrapper modules (e.g. src/components/Card/Card.ts) that:

  1. Re-export the semantic-ui-react component
  2. Import a companion CSS file with dark theme overrides (Card.css)

Previously, index.ts re-exported everything via export * from 'semantic-ui-react', bypassing these wrappers entirely. The CSS side-effect imports in the wrappers were never reached through the export chain.

This worked historically because bundlers like webpack and esbuild included all transitive modules regardless of reachability. However, tree-shaking bundlers like Rolldown (Vite 8) only follow the actual import/export graph. Since nothing imported the wrapper modules through the export chain, the CSS files were dropped from production builds — resulting in missing dark theme styles (white card backgrounds, wrong border-radius, missing shadows, etc.).

How it works

By routing exports through the wrapper modules, the CSS imports become part of the export chain:

// Before: CSS never reached
consumer → decentraland-ui/index.ts → semantic-ui-react (no CSS)

// After: CSS included via wrapper
consumer → decentraland-ui/index.ts → components/Card/Card.ts → Card.css ✓
                                                                → semantic-ui-react

Tree-shaking still works correctly — if a consumer doesn't import Card, neither Card.ts nor Card.css will be bundled.

Components re-routed through wrappers

Button, Card, Checkbox, Container, Dimmer, Dropdown, Header, Loader, Modal, Pagination, Popup, Radio, Segment, Table

Test plan

  • Verified dark theme CSS (Card background, border-radius, shadows) present in Rolldown/Vite 8 production build
  • No breaking changes to the public API — same exports, same import paths
  • Existing consumers (marketplace, builder) should be tested

Components like Card, Button, Modal, etc. have wrapper modules in
`src/components/` that re-export the semantic-ui-react component AND
import a companion CSS file with dark theme overrides. Previously,
`index.ts` re-exported these components directly from semantic-ui-react
via `export * from 'semantic-ui-react'`, bypassing the wrapper modules
entirely. The CSS side-effect imports in the wrappers were never reached
through the export chain.

This worked historically because bundlers like webpack and esbuild
included all transitive modules regardless of whether they were
reachable through exports. However, tree-shaking bundlers like Rolldown
(used in Vite 8) only follow the actual import/export graph. Since
nothing imported the wrapper modules, the CSS was dropped from
production builds, resulting in missing dark theme styles (white card
backgrounds, wrong border-radius, etc.).

The fix replaces the wildcard `export * from 'semantic-ui-react'` with:
- Explicit `export *` through each component wrapper that has CSS
  (Button, Card, Checkbox, Container, Dimmer, Dropdown, Header, Loader,
  Modal, Pagination, Popup, Radio, Segment, Table)
- Explicit named exports for the remaining semantic-ui-react components
  that have no CSS overrides

This ensures the CSS side-effect imports are part of the export chain
and will be included by any bundler that follows it. The public API
surface is unchanged — consumers still import the same components from
the same paths.
@vercel

vercel Bot commented Apr 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
decentraland-ui Ready Ready Preview, Comment Apr 3, 2026 10:32pm

Request Review

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.

1 participant