Prerequisites: make sure you have node >=8 and npm >=5
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
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
- AST exploer: an online tool to explore ASTs generated by mor ethan 10 parsers
- JavaScript AST Visualizer: an online tool that uses
Esprima
to parse the JavaScript code and displays via diagramming - jscodeshift: A JavaScript codemod toolkit
- Talk 📢: Hiking Throught the JavaScript Forest
- Article 📝: Turbocharged JavaScript Refactoring with Codemod at Airbnb
Jay Kan 💻 📖 💡 |
---|
This project follows the all-contributors specification. Contributions of any kind welcome!
MIT © Jay Kan