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
- Host: GitHub
- URL: https://github.com/kentcdodds/babel-codemod-example
- Owner: kentcdodds
- Created: 2017-02-22T17:26:46.000Z (over 8 years ago)
- Default Branch: main
- Last Pushed: 2021-01-25T23:22:58.000Z (over 4 years ago)
- Last Synced: 2025-04-23T00:08:52.947Z (6 months ago)
- Topics: ast, babel, codemod, esmodules, example, javascript, kcd-edu
- Language: JavaScript
- Homepage: http://kcd.im/babel-codemod-video
- Size: 13.7 KB
- Stars: 26
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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.