6

I'm trying to run the top-level-imports codemod found here: https://github.com/mui-org/material-ui/blob/master/packages/material-ui-codemod/README.md#top-level-imports.

So I ran npm install -D @material-ui/codemod and then I ran the script find src -name '*.tsx' -print | xargs npx jscodeshift -t node_modules/@material-ui/codemod/lib/v4.0.0/top-level-imports.js and I get the following error output:

Processing 1 files... 
Spawning 1 workers...
Sending 1 files to free worker...
 ERR ./components/form/TextField.tsx Transformation error (Cannot find module '@material-ui/core/es')
Error: Cannot find module '@material-ui/core/es'
    at Function.Module._resolveFilename (module.js:536:15)
    at Function.resolve (internal/module.js:18:19)
    at transformer (.../node_modules/@material-ui/codemod/lib/v4.0.0/top-level-imports.js:29:54)
All done. 

Has anyone encountered this before?

ha1ogen
  • 13,375
  • 3
  • 19
  • 19
  • I have the same issue. Not sure what to do. Did you figure it out? – mr.bjerre Oct 29 '20 at 20:19
  • No I didn't, but I realized that this shouldn't be an issue if you are using tree-shaking with Webpack. So I didn't bother updating my imports. – ha1ogen Nov 10 '20 at 06:03

1 Answers1

0

I assume the issue might be because we are trying to access the import specifiers from path.node.specifiers instead it should be path.value. here https://github.com/mui/material-ui/blob/b9423b64a3986fa2f0ed14af38afa3e2de7b07be/packages/mui-codemod/src/v4.0.0/top-level-imports.js#L28

Rajasegar
  • 86
  • 4