Skip to content

limpbrains/direct-import-codemod

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

direct-import-codemod

JS codemod to use with facebook/jscodeshift.

Based on awesome example by @JamieMason JamieMason/codemods.

Installation

git clone https://github.com/limpbrains/direct-import-codemod.git
cd direct-import-codemod
npm install

Usage

# yarn
yarn direct-import <path-to-file> -- --module '@material-ui/core'

# npm
npm run direct-import <path-to-file> -- --module '@material-ui/core'

# jscodeshift
jscodeshift -t ./transforms/direct-import.js <path-to-file> --module '@material-ui/core'

This will replace one import of @material-ui/core to number of separate imports

-import { Button, Dialog } from '@material-ui/core';
+import Button from "@material-ui/core/Button";
+import Dialog from "@material-ui/core/Dialog";

About

Use direct imports to save JS bundle size

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published