question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Expose `@material-ui/core/utils` from top-level `@material-ui/core`

See original GitHub issue
  • 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.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:19 (19 by maintainers)

github_iconTop GitHub Comments

1reaction
oliviertassinaricommented, Mar 31, 2020

That one is definitely not private.

@eps1lon I think that it’s up to us to decide what’s public and what’s private. We could very say it’s private, as long as we didn’t document it. The only exception would be the barrel index of @material-ui/core that we have repeatedly committed, in the past, to considering public if exported.


@NMinhNguyen Ok, so that was for the current state of affair, regarding the target we should have. I think that we should make modules public based on the value it can potentially bring to users. We have on the verge of a v5, so we will be able to make plenty of BCs anyway.

I would propose the following public modules

  • capitalize
  • createSvgIcon
  • deprecatedPropType
  • unsupportedProp
  • useForkRef
  • useEventCallback
  • useControlled
  • isMuiElement
  • @material-ui/utils
  • ownerWindow
  • debounce
  • ownerDocument

Which leaves us with these modules private

  • useIsFocusVisible
  • setRef
  • scrollLeft
  • createChainedFunction
  • getScrollbarSize
1reaction
eps1loncommented, Mar 31, 2020

I think that we can put @material-ui/utils in the same category: private (because not documented).

That one is definitely not private. Though breaking changes aren’t a problem there since we can be more liberal with version bumps.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Expose `@material-ui/core/utils` from top-level ... - GitHub
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...
Read more >
Minimizing bundle size - Material UI - MUI
MUI exposes its full API on the top-level @mui imports. If you're using ES6 modules and a bundler that supports tree-shaking ( webpack...
Read more >
javascript - material-ui 'createSvgIcon' is not exported from ...
js Attempted import error: 'createSvgIcon' is not exported from '@material-ui/core/utils'. So I tried to google this problem and found another ...
Read more >
@material-ui/utils | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
material-ui/core/CHANGELOG.md - UNPKG
The CDN for @material-ui/core. ... 834, - [core] Export core utils modules from barrel (#20354) @NMinhNguyen. 835, - [core] Improve out-of-date PR story ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found