Codemods to transform from or to the export-default-from syntax
-
git clone https://github.com/cangoektas/export-default-from-codemod.gitor download a zip file fromhttps://github.com/cangoektas/export-default-from-codemod/archive/master.zip -
Run
yarn installornpm installfrom inside the directory -
jscodeshift -t <codemod-script> <path>-
codemod-script- path to the transform file, see available scripts below; -
path- files or directory to transform -
use the
-doption for a dry-run and use-pto print the output for comparison; -
use the
--extensionsoption if your files have different extensions than.js(for example,--extensions js,jsx); -
see all available jscodeshift options.
-
- Setting the
parseroption forjscodeshiftdoes not have any effect because the transform script always usesbabylon - If you need additional Babel plugins enabled, you can update the
BABEL_PLUGINSarray in the transform script
Transforms this:
export { default as hello } from "world";
export { default as foo, bar } from "foo";into this:
export hello from "world";
export foo, { bar } from "foo";jscodeshift -t export-default-from-codemod/transforms/default-as-to-default-from.js <path>COMING SOON
MIT