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

[icons-material] Importing from @mui/icons-material throws error in Remix/Vite #44265

Closed
1 task done
Tracked by #43938
ramiroazar opened this issue Oct 30, 2024 · 4 comments
Closed
1 task done
Tracked by #43938
Assignees
Labels
bug 🐛 Something doesn't work package: icons Specific to @mui/icons

Comments

@ramiroazar
Copy link

ramiroazar commented Oct 30, 2024

Search keywords

module, cjs, mjs, icons, vite, remix

Latest version

  • I have tested the latest version

Steps to reproduce

  1. Open reproduction
  2. Notice error

Current behavior

Importing an icon from @mui/icons-material throws the following warning and error.

Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.

Screenshot 2024-10-30 at 3 43 40 PM

SyntaxError: Cannot use import statement outside a module

Screenshot 2024-10-30 at 3 38 25 PM

Expected behavior

Importing an icon from @mui/icons-material shouldn't throw an error.

Context

We're trying to use @mui/icons-material in a Remix project.

Your environment

npx @mui/envinfo
System:
    OS: macOS 14.5
  Binaries:
    Node: 22.2.0 - ~/.nvm/versions/node/v22.2.0/bin/node
    npm: 10.7.0 - ~/.nvm/versions/node/v22.2.0/bin/npm
    pnpm: Not Found
  Browsers:
    Chrome: 130.0.6723.91
    Edge: Not Found
    Safari: 17.5
  npmPackages:
    @mui/core-downloads-tracker:  6.1.5 
    @mui/icons-material: ^6.1.5 => 6.1.5 
    @mui/material:  6.1.5 
    @mui/private-theming:  6.1.5 
    @mui/styled-engine:  6.1.5 
    @mui/system:  6.1.5 
    @mui/types:  7.2.18 
    @mui/utils:  6.1.5 
    @types/react: ^18.2.20 => 18.3.10 
    react: ^18.2.0 => 18.3.1 
    react-dom: ^18.2.0 => 18.3.1 
    typescript: ^5.1.6 => 5.6.2
@ramiroazar ramiroazar added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Oct 30, 2024
@zannager zannager added the package: icons Specific to @mui/icons label Oct 30, 2024
@joebochill
Copy link

In case this helps anyone else, I ran into the same error while trying to migrate a simple Vite project to use the new PigmentCSS engine (removing all of my ownerState instances). One of the overrides in my theme set a default property to a different icon. I read a little further ahead in the migration guide and after switching to using the DefaultPropsProvider, the error went away.

@siriwatknp siriwatknp assigned Janpot and unassigned siriwatknp Nov 13, 2024
@DiegoAndai
Copy link
Member

Thanks for the report @ramiroazar, this is a bug.

@Janpot this looks like the same root cause that #43980 (comment). Is it?

@DiegoAndai DiegoAndai added bug 🐛 Something doesn't work and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Nov 29, 2024
@DiegoAndai DiegoAndai changed the title Importing from @mui/icons-material throws error [icons-material] Importing from @mui/icons-material throws error in Remix/Vite Nov 29, 2024
@Janpot Janpot mentioned this issue Jan 7, 2025
30 tasks
@DiegoAndai DiegoAndai added this to the Material UI v7 milestone Jan 22, 2025
@DiegoAndai DiegoAndai moved this to Backlog in Material UI Jan 22, 2025
@Janpot
Copy link
Member

Janpot commented Feb 12, 2025

Works with latest alpha which changed the package layout to valid dual ESM/commonjs packages, I also had to install peer dependency @emotion/styled. See sandbox for a fixed reproduction.

@Janpot Janpot closed this as completed Feb 12, 2025
@github-project-automation github-project-automation bot moved this from Backlog to Done in Material UI Feb 12, 2025
Copy link

This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

Note

@ramiroazar How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work package: icons Specific to @mui/icons
Projects
Status: Done
Development

No branches or pull requests

6 participants