Skip to content

build(package): annotate sideEffects for CSS tree-shaking#1962

Merged
kotAPI merged 1 commit into
mainfrom
fix/issue-1846-side-effects
Jun 13, 2026
Merged

build(package): annotate sideEffects for CSS tree-shaking#1962
kotAPI merged 1 commit into
mainfrom
fix/issue-1846-side-effects

Conversation

@kotAPI

@kotAPI kotAPI commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Adds sideEffects for CSS/SCSS so bundlers can tree-shake unused JS while preserving stylesheet imports.
  • Documents the annotation and maintainer checklist in contributing docs.

Closes #1846.

Test plan

  • npm run check:exports passes on commit.
  • Confirm bundlers retain @radui/ui/themes/default.css imports when components are tree-shaken.

Made with Cursor

Summary by CodeRabbit

  • Documentation

    • Added comprehensive guide on side effects and tree-shaking, covering best practices for component imports, CSS management, avoiding unnecessary re-exports, and a maintainer checklist for handling side-effect modules.
  • Chores

    • Added sideEffects configuration to mark CSS and SCSS files in package.json.

Closes #1846.

Co-authored-by: Cursor <cursoragent@cursor.com>
@changeset-bot

changeset-bot Bot commented Jun 12, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: f089430

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5369fa02-a058-4faf-8f58-73015e1c3118

📥 Commits

Reviewing files that changed from the base of the PR and between b05c1b2 and f089430.

📒 Files selected for processing (5)
  • docs/app/docs/contributing/side-effects-and-tree-shaking/content.mdx
  • docs/app/docs/contributing/side-effects-and-tree-shaking/page.tsx
  • docs/app/docs/contributing/side-effects-and-tree-shaking/seo.ts
  • docs/app/docs/docsNavigationSections.tsx
  • package.json

📝 Walkthrough

Walkthrough

This PR adds package-level sideEffects configuration for CSS and SCSS files, creates a new contributing documentation page explaining side-effects behavior and consumption guidance, establishes the page wiring with SEO metadata, and integrates the page into the docs navigation menu.

Changes

Side Effects & Tree-Shaking Documentation

Layer / File(s) Summary
Package-level side effects declaration
package.json
sideEffects field is added to mark **/*.css and **/*.scss globs as having side effects for bundler tree-shaking.
Side-effects documentation page
docs/app/docs/contributing/side-effects-and-tree-shaking/content.mdx, docs/app/docs/contributing/side-effects-and-tree-shaking/page.tsx, docs/app/docs/contributing/side-effects-and-tree-shaking/seo.ts
MDX content explains the Rad UI sideEffects configuration, provides consumer import recommendations, and includes a maintainer checklist. The page is wired with Next.js metadata export and creates the docs page component using the content and SEO metadata.
Navigation integration
docs/app/docs/docsNavigationSections.tsx
Contributing navigation section is updated to include a "Side Effects & Tree-shaking" entry pointing to the new documentation page.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • rad-ui/ui#1064: Introduces generateSeoMetadata utility used in the new page's seo.ts file.
  • rad-ui/ui#901: Modifies docs navigation rendering logic that impacts how the new contributing page appears in navigation.

Poem

🐰 A side effect found, no tree shall shake,
CSS styled, for bundlers' sake!
Docs now guide both user and coder,
Tree-shaking cleaner, with leaf-dropping encoder. 📦✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change: adding sideEffects annotations to package.json for CSS tree-shaking, which is the primary focus of this PR.
Linked Issues check ✅ Passed The PR addresses all key objectives from #1846: sideEffects annotations are reviewed and updated for CSS/SCSS, tree-shaking behavior is documented, and comprehensive consuming guidance is provided.
Out of Scope Changes check ✅ Passed All changes directly support the core objective of documenting and annotating sideEffects for CSS tree-shaking; documentation additions align with acceptance criteria requirement for docs updates.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-1846-side-effects

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed due to a network error.


Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown
Contributor

Coverage

This report compares the PR with the base branch. "Δ" shows how the PR affects each metric.

Metric PR Δ
Statements 75.68% +0.00%
Branches 59.08% +0.00%
Functions 61.75% +0.00%
Lines 77.22% +0.00%

Coverage improved or stayed the same. Great job!

Run npm run coverage:ci locally for detailed reports and target untested areas to raise these numbers.

@kotAPI kotAPI added the Resolution: Needs Investigation This issue requires further investigation label Jun 12, 2026
@kotAPI kotAPI merged commit 3a6b29d into main Jun 13, 2026
13 of 14 checks passed
@kotAPI kotAPI deleted the fix/issue-1846-side-effects branch June 13, 2026 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Resolution: Needs Investigation This issue requires further investigation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add sideEffects annotations review for optimal tree-shaking.

1 participant