Skip to content

ThemeProvider: stop bundling the legacy JS theme with the root entry #8722

Open

Description

@mattcosta7

Part of #8676 (P2). Breaking change. This needs a decision on major-version timing before anyone starts.

Problem

ThemeProvider.tsx:5 imports theme.ts, which imports legacy-theme/ts/color-schemes.ts (327 KB of source). index.ts:3 also exports theme. Every consumer of the root entry therefore ships and evaluates the legacy theme.

Measured: with esbuild on theme.ts alone:

  • 275 KB minified.
  • 20 KB gzipped. The gzipped size is small because the data repeats, but parse and evaluation cost follows the 275 KB.

The per-provider deepmerge(theme, scheme) is cheap: 0.4 to 0.6 ms warm and 1.5 to 3 ms on the first call.

@primer/react/next already avoids the theme import, and the root ThemeProvider is deprecated in favor of it.

Proposed approach

  • Decide which major release removes the default theme from the root ThemeProvider and the root theme export.
  • Ship a migration path, either @primer/react/next or an explicit theme prop import.
  • Consider shipping this alongside ThemeProvider: Deprecate redundant day and night color modes #3246 (deprecate the day and night color modes), another breaking ThemeProvider change for the next major.

Acceptance criteria

  • The target major release is decided and recorded here.
  • Importing the root entry no longer pulls in legacy-theme/ts/color-schemes.ts. Verify with a bundle analysis.
  • Migration guidance is published for consumers that rely on the default theme or the theme export.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions