[codemod] Top-Level-Imports codemod adds some named imports that aren't exported from the top level package
Open
Nobody has claimed this yet.
package: codemod
ready to take
scope: all components
type: bug
- Dominant language
- JavaScript
- Stars
- 99.1k
- Forks
- 32.5k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 106
Description
Duplicates
- I have searched the existing issues
Latest version
- I have tested the latest version
Current behavior 😯
After running the top-level-imports codemod, I found that it attempts to import some things incorrectly.
- { TransitionProps } named import from '@mui/material' but it actually needs to be imported from '@mui/material/transitions';
- { common } from '@mui/material' should be '@mui/material/colors'
I'm not sure if these imports were intentionally left out of the main package exports, or if that was a mistake, but the codemod doesn't make the distinction.
Expected behavior 🤔
The top-level-imports codemod should not change imports to named imports for items that aren't exported from the top level package.
Steps to reproduce 🕹
Steps:
- Create a file with: ```
import { TransitionProps } from '@mui/material/transitions';
import { common } from '@mui/material/colors';
2. Run `top-level-imports on that file.
3. See it combine these into ```
import { TransitionProps, common } from '@mui/material'
- Run TSC and notice that typescript informs you that these modules are not exported from '@mui/material'
Context 🔦
No response
Your environment 🌎
`npx @mui/envinfo`
System:
OS: macOS 12.0
Binaries:
Node: 16.14.2 - ~/.nvm/versions/node/v16.14.2/bin/node
Yarn: 1.22.17 - /opt/homebrew/bin/yarn
npm: 8.5.0 - ~/.nvm/versions/node/v16.14.2/bin/npm
Browsers:
Chrome: 102.0.5005.61
Edge: Not Found
Firefox: 98.0.2
Safari: 15.0
npmPackages:
@emotion/react: ^11.7.1 => 11.7.1
@emotion/styled: ^11.6.0 => 11.6.0
@mui/base: ^5.0.0-alpha.68 => 5.0.0-alpha.68
@mui/icons-material: ^5.5.1 => 5.5.1
@mui/lab: ^5.0.0-alpha.67 => 5.0.0-alpha.67
@mui/material: ^5.4.0 => 5.4.0
@mui/private-theming: 5.3.0
@mui/styled-engine: 5.3.0
@mui/styles: ^5.3.0 => 5.3.0
@mui/system: ^5.4.0 => 5.4.0
@mui/types: 7.1.0
@mui/utils: 5.3.0
@types/react: ^17.0.2 => 17.0.3
react: 17.0.1 => 17.0.1
react-dom: 17.0.1 => 17.0.1
styled-components: 5.2.3 => 5.2.3
typescript: ^4.3.2 => 4.5.5
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.