Skip to content

Core: Simplify @emotion/react module augmentation#33250

Merged
ndelangen merged 2 commits into
storybookjs:nextfrom
mrginglymus:no-theme-shim
Dec 23, 2025
Merged

Core: Simplify @emotion/react module augmentation#33250
ndelangen merged 2 commits into
storybookjs:nextfrom
mrginglymus:no-theme-shim

Conversation

@mrginglymus
Copy link
Copy Markdown
Contributor

@mrginglymus mrginglymus commented Dec 1, 2025

What I did

The previous approach would overwrite the inlined declaration of the Theme interface from @emotion/react.

This alternative approach contains a self-augmenting declaration that enhances the Theme interface re-export.

Type checking is working locally in dev and prod.

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

No specific manual testing required, type changes only.

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli-storybook/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook publish.yml --field pr=<PR_NUMBER>

Summary by CodeRabbit

  • Refactor
    • Simplified internal theming type export structure and streamlined the build process.

✏️ Tip: You can customize this high-level summary in your review settings.

The previous approach would overwrite the inlined declaration of the
Theme interface from @emotion/react.

This alternative approach contains a self-augmenting declaration that
enhances the Theme interface re-export.
@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Dec 1, 2025

View your CI Pipeline Execution ↗ for commit 56264cd


☁️ Nx Cloud last updated this comment at 2025-12-22 22:55:02 UTC

@valentinpalkovic valentinpalkovic added the build Internal-facing build tooling & test updates label Dec 2, 2025
@ghengeveld ghengeveld requested a review from ndelangen December 8, 2025 14:29
@github-actions github-actions Bot added the Stale label Dec 22, 2025
@ndelangen ndelangen removed the Stale label Dec 22, 2025
@ndelangen ndelangen changed the title Simplify @emotion/react module augmentation Core: Simplify @emotion/react module augmentation Dec 22, 2025
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 22, 2025

📝 Walkthrough

Walkthrough

The theming module's type augmentation strategy was refactored. The separate Emotion augmentation file and build-time type modification utility were removed, moving theme augmentation directly into the main theming index module. This eliminates post-processing steps from the build pipeline.

Changes

Cohort / File(s) Summary
Theming Module Reorganization
code/core/src/theming/emotionAugmentation.d.ts, code/core/src/theming/index.ts
Deleted emotionAugmentation.d.ts. Removed re-export from index.ts, added module augmentation that extends Theme interface to include StorybookTheme, and re-exported Theme directly from @emotion/react.
Build Pipeline Simplification
scripts/build/build-package.ts, scripts/build/utils/generate-types.ts
Removed import and call to modifyCoreThemeTypes function from both files, eliminating post-generation type modification step from the build process.
Type Modification Utility Removal
scripts/build/utils/modify-core-theme-types.ts
Deleted entire utility file that previously performed conditional post-processing of generated theme types during the build.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

✨ Finishing touches
  • 📝 Generate docstrings

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0fcdf47 and 56264cd.

📒 Files selected for processing (5)
  • code/core/src/theming/emotionAugmentation.d.ts
  • code/core/src/theming/index.ts
  • scripts/build/build-package.ts
  • scripts/build/utils/generate-types.ts
  • scripts/build/utils/modify-core-theme-types.ts
💤 Files with no reviewable changes (4)
  • scripts/build/utils/modify-core-theme-types.ts
  • code/core/src/theming/emotionAugmentation.d.ts
  • scripts/build/utils/generate-types.ts
  • scripts/build/build-package.ts
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{js,jsx,ts,tsx,json,md,html,css,scss}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Format code using Prettier with yarn prettier --write <file>

Files:

  • code/core/src/theming/index.ts
**/*.{js,jsx,json,html,ts,tsx,mjs}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Run ESLint checks using yarn lint:js:cmd <file> or the full command cross-env NODE_ENV=production eslint --cache --cache-location=../.cache/eslint --ext .js,.jsx,.json,.html,.ts,.tsx,.mjs --report-unused-disable-directives to fix linting errors before committing

Files:

  • code/core/src/theming/index.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Enable TypeScript strict mode across all packages

Files:

  • code/core/src/theming/index.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{ts,tsx,js,jsx}: Export functions from modules if they need to be tested
Do not use console.log, console.warn, or console.error directly unless in isolated files where importing loggers would significantly increase bundle size

Files:

  • code/core/src/theming/index.ts
code/{core,lib,addons,builders,frameworks,presets}/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use logger from storybook/internal/node-logger for server-side logging in Node.js code

Files:

  • code/core/src/theming/index.ts
🧠 Learnings (3)
📚 Learning: 2025-12-22T22:03:40.109Z
Learnt from: CR
Repo: storybookjs/storybook PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-22T22:03:40.109Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Export functions from modules if they need to be tested

Applied to files:

  • code/core/src/theming/index.ts
📚 Learning: 2025-11-05T09:38:47.712Z
Learnt from: Sidnioulz
Repo: storybookjs/storybook PR: 32458
File: code/core/src/components/components/Select/Select.tsx:200-204
Timestamp: 2025-11-05T09:38:47.712Z
Learning: Repo: storybookjs/storybook — Guidance: Until Storybook 11 is released, do not suggest using React.useId anywhere (e.g., in code/core/src/components/components/Select/Select.tsx) to maintain compatibility with React 17 runtimes. Prefer advising: accept a caller-provided props.id and, if needed, generate a client-only fallback id to minimize SSR hydration issues — but avoid useId. Resume prompting for useId after Storybook 11.

Applied to files:

  • code/core/src/theming/index.ts
📚 Learning: 2025-11-05T09:37:25.920Z
Learnt from: Sidnioulz
Repo: storybookjs/storybook PR: 32458
File: code/core/src/components/components/tooltip/WithTooltip.tsx:54-96
Timestamp: 2025-11-05T09:37:25.920Z
Learning: Repo: storybookjs/storybook — In code/core/src/components/components/tooltip/WithTooltip.tsx, the legacy WithTooltip implementation is intentionally reintroduced for backward compatibility and is deprecated; maintainers (per Sidnioulz) do not want maintenance or improvements on it. Prefer WithTooltipNew/Popover; avoid suggesting changes to WithTooltip.* going forward.

Applied to files:

  • code/core/src/theming/index.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: normal
  • GitHub Check: Core Unit Tests, windows-latest

Comment on lines +45 to +50

// Re-export Theme from @emotion/react and self-augment with StorybookTheme
declare module '.' {
interface Theme extends StorybookTheme {}
}
export type { Theme } from '@emotion/react';

This comment was marked as spam.

@ndelangen ndelangen merged commit 821b832 into storybookjs:next Dec 23, 2025
67 of 76 checks passed
@github-actions github-actions Bot mentioned this pull request Dec 23, 2025
22 tasks
@mrginglymus mrginglymus deleted the no-theme-shim branch December 23, 2025 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Internal-facing build tooling & test updates ci:normal core theming

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants