This is a codemod script for use with
JSCodeshift that helps convert lodash
method package imports/requires (e.g. lodash.mapvalues
) to imports from lodash
submodules (e.g. lodash/mapValues
)
yarn global add jscodeshift
git clone https://github.com/jcoreio/jscodeshift-replace-lodash-method-packages.git
- Run
yarn install
in the cloned directory jscodeshift -t <path/to>/jscodeshift-replace-lodash-method-packages/index.js <path>
path
- files or directory to transform;- use the
-d
option for a dry-run and use-p
to print the output for comparison; - use the
--extensions
option if your files have different extensions than.js
(for example,--extensions js,jsx
); - if you use flowtype, you might also need to use
--parser=flow
or--parser=babylon
; - see all available jscodeshift options.