Skip to content

JayKan/babel-codemod

Repository files navigation

babel-codemod

Use Babel to codemod your code ✌️

Build Status Dependencies Conventional Commits MIT License PRs Welcome All Contributors Code of Conduct

Prerequisites: make sure you have node >=8 and npm >=5

The Problem

When ES modules land in Node.js, it's possible to the following:

import { foo } from '/foo';

However since CommonJS is not statically analyzable, typically we would do something like this in our current Node code base:

import fs, { readFile } from 'fs'; // it works ok if you use Babel to transpile

The solution

Use our custom babel-plugin to codemod your code programatically 💪. To see exactly how this plugin works please follow:

$ git clone

$ nvm use

$ npm install

# see dist/demo/**.js for our transformed code
$ npm run build

# or you can simply run below command to see our transformed code in terminal
$ npm run demo

Resrouces

Contributors


Jay Kan

💻 📖 💡

This project follows the all-contributors specification. Contributions of any kind welcome!

License

MIT © Jay Kan

About

An example of how to use babel as a codemod

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published