Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] True ESM support #43938

Open
26 of 32 tasks
oliviertassinari opened this issue Sep 29, 2024 · 7 comments
Open
26 of 32 tasks

[core] True ESM support #43938

oliviertassinari opened this issue Sep 29, 2024 · 7 comments
Assignees
Labels
breaking change scope: code-infra Specific to the core-infra product umbrella For grouping multiple issues to provide a holistic view

Comments

@oliviertassinari
Copy link
Member

oliviertassinari commented Sep 29, 2024

Steps to reproduce

I'm creating this issue as an umbrella to solve ESM support in Material UI v7.

What does success looks like?

Current behavior

No response

Expected behavior

No response

Context

No response

Your environment

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

Search keywords: -

@oliviertassinari oliviertassinari added umbrella For grouping multiple issues to provide a holistic view breaking change status: waiting for maintainer These issues haven't been looked at yet by a maintainer v7.x labels Sep 29, 2024
@oliviertassinari oliviertassinari added scope: code-infra Specific to the core-infra product and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer v7.x labels Sep 29, 2024
@DiegoAndai
Copy link
Member

One of the proposals in #35233 was changing the icons package to be ESM only. This would help reduce the size of the package to 2/3 of its current size (keep type definitions and ESM, remove CJS). Should we do that for v7? @Janpot

@Janpot
Copy link
Member

Janpot commented Dec 19, 2024

for v7 I'd like to go to dual mode packages with exports field and a single layout that's the same across all packages. Personally I think if we go ESM only with one package we should do it for all. The less we confuse bundlers, the better 🙂

@DiegoAndai
Copy link
Member

That makes sense 👍🏼

@o-alexandrov
Copy link
Contributor

o-alexandrov commented Feb 15, 2025

Idk whether the following issue is considered expected, as it's an alpha version.
Just fyi, when using 7.0.0-alpha.1 and importing:

import zIndexMui from "@mui/material/styles/zIndex"

the following error happens:

  The module "./esm/styles/zIndex/index.js" was not found on the file system:

    ../node_modules/@mui/material/package.json:95:19:
      95 │         "default": "./esm/*/index.js"~~~~~~~~~~~~~~~~~~

As I understand it, the issue is due to either:

  • invalid default directive in @mui/material/package.json
  • or you might want to consider to export zIndex from styles/index.js

The released zIndex doesn't have an index.js file.
It's located at:

node_modules/@mui/material/esm/styles/zIndex.js

@Janpot
Copy link
Member

Janpot commented Feb 17, 2025

Idk whether the following issue is considered expected

It is expected, we don't consider subpath imports more than one level deep part of our public API. v7 will more strongly enforce that. We're documenting this in the upcoming migration guide.

As for your use-case, I suppose our intention would be to read the default z-index from the default theme.

import { createTheme } from '@mui/material/styles'
const { zIndex } = createTheme()

cc @siriwatknp would it make sense to separately export the default z-index from @mui/material/styles? Or perhaps it would make sense to memoize the default theme on multiple calls to createTheme to reduce the impact of calling it multiple times?

We could also more explicitly define our exports in package.json instead of using the wildcard

@cmdcolin
Copy link
Contributor

cmdcolin commented Feb 28, 2025

not sure if it is expected, but @mui/icons-material v7 beta.2 does not find the types with moduleResolution:node(?)

example https://stackblitz.com/edit/react-vjasx57o?file=Demo.tsx

screenshot

Image

i see similar error with a local project as the stackblitz too

Example error I see locally

packages/core/ui/DraggableDialog.tsx:3:23 - error TS7016: Could not find a declaration file for module '@mui/icons-material/Close'. '/home/cdiesh/src/jbrowse-components/node_modules/@mui/icons-material/Close.js' implicitly has an 'any' type.
  There are types at '/home/cdiesh/src/jbrowse-components/node_modules/@mui/icons-material/esm/icon.d.ts', but this result could not be resolved under your current 'moduleResolution' setting. Consider updating to 'node16', 'nodenext', or 'bundler'.

3 import CloseIcon from '@mui/icons-material/Close'
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~

@Janpot
Copy link
Member

Janpot commented Feb 28, 2025

Fixing it in #45444

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change scope: code-infra Specific to the core-infra product umbrella For grouping multiple issues to provide a holistic view
Projects
Status: In progress
Development

No branches or pull requests

5 participants