Skip to content

Expose @material-ui/core/utils from top-level @material-ui/core #20353

@NMinhNguyen

Description

@NMinhNguyen
  • I have searched the issues of this repository and believe that this is not a duplicate.

Summary 💡

// packages/material-ui/src/index.js
+ export * from './utils';

Examples 🌈

import { useForkRef } from '@material-ui/core'

Motivation 🔦

I may be mistaken, but from what I gather, @material-ui/core/utils is probably safe to import since it has typings, is a 2nd level import, and is imported by another package, @material-ui/lab, although strictly speaking there's no docs. There's also mention of making setRef private, which suggests that utils are currently public.

The main motivation to export it from the top-level @material-ui/core is UMD bundles - we have a design system where we'd like to externalise @material-ui/core but we're currently importing a few things from utils and thus we can't just do e.g. import { useForkRef } from '@material-ui/core'. There are a few userland workarounds like copying and pasting the utils, or somehow still bundling in nested imports like @material-ui/core/utils (as in, not externalising), but we'd like to avoid that if possible. Another module we're currently relying on is @material-ui/core/styles/zIndex but that one we should be able to retrieve by calling createMuiTheme and extracting it from there instead, so not that much of a problem.

Presumably, if @material-ui/lab was to provide a UMD bundle, it would run into this constraint as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    internalBehind-the-scenes enhancement. Formerly called “core”.type: new featureExpand the scope of the product to solve a new problem.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions