A collection of codemods that allow you to transform your js code from ES5 to ES6 using jscodeshift.
npm install -g jscodeshiftnpm install 5to6-codemodjscodeshift -t node_modules/5to6-codemod/transforms/[transform].js [files]- Review changes via
git diff. Keep what you want, throw it out if you don't. Magic!
amd- Transforms AMD style modules to ES6import/exportcjs- Transforms CommonJS stylerequire()calls to ES6importstatementsno-strict- Removes "use strict" statementsexports- Move CommonJS stylemodule.exportsstatements to ES6exportstatementslet- Replace allvarcalls to uselet
- Currently loses comments if directly before the
require()statement. require()calls in single var statements get reordered, and moved before the single var after conversion to import.- Can't automagically figure out when you want to use
import * as varName. - End-of-line comments also missing in many situations