Skip to content

[x-internals] Re-export tier-2 generic utilities from @base-ui/utils - #23374

Draft
romgrk wants to merge 2 commits into
mui:masterfrom
romgrk:x-internals-tier2-base-ui-utils
Draft

[x-internals] Re-export tier-2 generic utilities from @base-ui/utils#23374
romgrk wants to merge 2 commits into
mui:masterfrom
romgrk:x-internals-tier2-base-ui-utils

Conversation

@romgrk

@romgrk romgrk commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Part of the x-internals → @base-ui/utils deduplication (follows the store move). Consumes mui/base-ui#5542 and converts the moved modules into re-exports, deleting ~1,500 lines of duplicated implementation and tests (the tests moved to base-ui with the code).

Draft until mui/base-ui#5542 is released — the catalog pins @base-ui/utils to a pkg.pr.new preview of that PR (@d1e1c9a); revert to a released version before merging (TODO comment in pnpm-workspace.yaml).

Converted to re-exports

disposable, useDisposable, fastMemo, forwardRef, hash, isDeepEqual, domUtils/isHTMLElement, isObjectEmpty, export/loadStyleSheets, lruMemoize, math, rafThrottle, slots, throttle, generic types, useEffectAfterFirstRender, useIsHydrated, useResizeObserver, useRunOnce.

All public entry points (@mui/x-internals/*) and export names are unchanged. Upstream renamed useRunOnce to useLayoutEffectRunOnce, which is aliased back here so @mui/x-internals/useRunOnce keeps its name.

Kept in x-internals

  • X-specific types: MuiEvent, GridChartsIntegration, SlotComponentPropsFromProps (depends on @mui/utils/types).
  • Tier-1 near-duplicates (getTarget, fastObjectShallowCompare, warning, formatErrorMessage, useFirstRender, platform, reactMajor) — handled in a separate effort.
  • EventManager, ToolbarContext, useAssertModelConsistency, useComponentRenderer.

Validation

  • pnpm test:jsdom packages/x-internals — 18 passed.
  • pnpm test:jsdom packages/x-tree-view — 994 passed (exercises useDisposable).
  • pnpm typescriptfails with 5 pre-existing errors unrelated to this PR (see below).

Known blocker: store API tightening on base-ui master

pnpm typescript reports 5 errors, all at @base-ui/utils/store call sites and none in code this PR touches:

  • x-scheduler-internals/.../SchedulerStore.ts:280 and use-event-calendar/EventCalendarStore.ts:193Partial<State> not assignable to Pick<State, Key>
  • x-scheduler-internals-premium/.../dataSource.test.ts:924,942,960store.set(...) not callable

Cause: the Store API tightened on base-ui master in mui/base-ui#5423, which any master preview carries.

update set
released @base-ui/utils@0.3.1 update(changes: Partial<State>) set<T>(key: keyof State, value: T)
base-ui master / this preview update<const Key extends keyof State>(changes: Pick<State, Key>) set<Key extends keyof State>(key: Key, value: State[Key])

Adapting those call sites belongs with the store migration work, not with this utils move, so they are left untouched here. This PR cannot go green until that lands.

🤖 Generated with Claude Code

Consumes mui/base-ui#5542 (pinned to a pkg.pr.new preview) and converts
the moved modules to re-exports: disposable, useDisposable, fastMemo,
forwardRef, hash, isDeepEqual, isHTMLElement, isObjectEmpty,
loadStyleSheets, lruMemoize, math, rafThrottle, slots, throttle,
generic types, useEffectAfterFirstRender, useIsHydrated,
useResizeObserver, useRunOnce.

X-specific types (MuiEvent, GridChartsIntegration,
SlotComponentPropsFromProps) stay. Tier-1 near-duplicates (getTarget,
fastObjectShallowCompare, warning, formatErrorMessage, useFirstRender,
platform, reactMajor) are handled separately.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions Bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Aug 20, 2026
@base-ui/utils renamed useRunOnce to useLayoutEffectRunOnce. Alias it
back so @mui/x-internals/useRunOnce keeps its current name, and bump
the preview pin to pick up the review fixes from mui/base-ui#5542.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: out-of-date The pull request has merge conflicts and can't be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant