require-default-codemod
v1.0.1
Published
Codemod that appends default property to CommonJS require.
Downloads
2
Maintainers
Readme
require-default-codemod
Codemod that appends default
property to CommonJS require
:
require-default-codemod [path] [...options]
To run the codemod in the current directory:
$ npx require-default-codemod .
Before JS file transformation:
require('foo');
After JS file transformation:
require('foo').default;
This codemod will not transform existing
require(/* ... */).default
.
See codemod on npm or read blog post.
Prerequisites
Usage
npx
Run codemod using npx:
$ npx require-default-codemod [path] [...options]
Global
Install and run codemod globally:
$ npm install --global require-default-codemod
$ require-default-codemod [path] [...options]
Local
Install and run codemod locally (requires jscodeshift):
$ npm install --global jscodeshift
$ npm install require-default-codemod
$ jscodeshift -t node_modules/require-default-codemod/require-default.js [path] [...options]
Path
Run codemod for file file.js
:
$ require-default-codemod file.js
Run codemod for directory directory
:
$ require-default-codemod directory
Options
Pass a configuration file to ignore files/patterns during transform:
$ require-default-codemod . --ignore-config .gitignore
node_modules
are ignored by default.
See more options.