Skip to content

fix(sentry): move @material-ui/core to peerDependencies to fix dark mode#7526

Closed
andreahlert wants to merge 1 commit intobackstage:mainfrom
andreahlert:fix/sentry-peer-deps
Closed

fix(sentry): move @material-ui/core to peerDependencies to fix dark mode#7526
andreahlert wants to merge 1 commit intobackstage:mainfrom
andreahlert:fix/sentry-peer-deps

Conversation

@andreahlert
Copy link
Contributor

@andreahlert andreahlert commented Feb 8, 2026

Hey, I just made a Pull Request!

Fixes #6537

The sentry plugin declared @material-ui/core and @material-table/core as direct dependencies. With strict package managers like pnpm, this creates a duplicate module instance where the ThemeProvider from UnifiedThemeProvider populates one copy's React Context, but the plugin's MUI components resolve to a separate copy with no theme context and fall back to the default light theme.

I reproduced this locally by running pnpm install on a minimal Backstage app with the sentry plugin. Two separate @material-ui/core@4.12.4 directories appear under .pnpm/:

  • @backstage/theme (provides ThemeProvider) -> copy 74b2
  • @material-table/core (renders Paper) -> copy 74b2
  • @backstage-community/plugin-sentry (Select, Grid, etc.) -> copy 7d94 (different instance)

With npm/yarn this is masked by hoisting, but with pnpm's strict isolation it breaks. Other plugins like todo don't have this problem because they don't declare @material-ui/core as a direct dependency.

Moving these to peerDependencies ensures the plugin always uses the host app's copy.

✔️ Checklist

  • A changeset describing the change and affected packages. (more info)
  • Added or updated documentation
  • Tests for new functionality and regression tests for bug fixes
  • Screenshots attached (for UI changes)
  • All your commits have a Signed-off-by line in the message. (more info)

@andreahlert andreahlert requested a review from a team as a code owner February 8, 2026 04:42
@andreahlert andreahlert requested review from awanlin and removed request for a team February 8, 2026 04:42
@backstage-goalie
Copy link
Contributor

Changed Packages

Package Name Package Path Changeset Bump Current Version
@backstage-community/plugin-sentry workspaces/sentry/plugins/sentry patch v1.14.0

…ependencies

These packages were declared as direct dependencies, which causes
duplicate module instances with strict package managers like pnpm.
The ThemeProvider from UnifiedThemeProvider ends up on one copy while
the plugin's MUI components resolve to a separate copy with no theme
context, falling back to the default light theme.

Moving them to peerDependencies ensures the plugin always uses the
host app's copy, sharing the same ThemeProvider context.

Fixes backstage#6537

Signed-off-by: André Ahlert <andre@aex.partners>
Copy link
Contributor

@awanlin awanlin left a comment

Choose a reason for hiding this comment

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

Hi @andreahlert, left a comment but this won't be the direction we want to go to solve this issue.

'@backstage-community/plugin-sentry': patch
---

Moved `@material-ui/core` and `@material-table/core` from `dependencies` to `peerDependencies` to fix dark mode rendering in strict package managers like pnpm. When declared as direct dependencies, these packages could resolve to a separate module instance, causing the plugin's MUI components to miss the ThemeProvider context and fall back to the default light theme.
Copy link
Contributor

Choose a reason for hiding this comment

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

Backstage doesn't support pnpm, just Yarn, this should be a framework level change not something we are doing on a per-plugin basis, we'd need to change every plugin in the eco-system.

Alternatively, migrating this plugin to use Backstage UI (BUI) and removing MUI completly would be an approved way to work around this.

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.

🐛 sentry: Always in light mode with Backstage UI

3 participants