require-default-codemod

1.0.1 • Public • Published

require-default-codemod

NPM

NPM version Build Status Coverage Status Dependency status

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.

License

MIT

Package Sidebar

Install

npm i require-default-codemod

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

7.66 kB

Total Files

6

Last publish

Collaborators

  • remarkablemark