An open API service indexing awesome lists of open source software.

https://github.com/kentcdodds/babel-codemod-example

An example of how to use babel as a codemod
https://github.com/kentcdodds/babel-codemod-example

ast babel codemod esmodules example javascript kcd-edu

Last synced: 6 months ago
JSON representation

An example of how to use babel as a codemod

Awesome Lists containing this project

README

          

# babel-codemod-example

When ES modules land in Node, it will be impossible to do this:

```javascript
import {thing} from './common-js-module'
```

Because CommonJS is not statically analyzable. However many people (myself included) have been doing this for a long time:

```javascript
import {readFile} from 'fs'
```

In [this quick video](http://kcd.im/babel-codemod-video), I show you a quick babel plugin I wrote to do a codemod on my code to fix this automatically.