Require To Imports
Take your old files that use AMD require.
break them. turn them into files that use es6 imports!
The transpiler focuses on code written using the
define() function, either with an array of paths as the first argument:
with a bunch of require declarations
These transpile into:
node index tr -r './myoldsauce' './mynewsauce'
This will read all files in your
myoldsauce folder, transpile them and output them into the
mynewsauce folder. I recommend not transpiling into the same dir
tr command takes the following options
-r, --recursive, transpile recursively
-l, --verbose, verbose
-f, --fix, fix path strings, this adds "./" to the begining of input paths
-h, --help, shows usage information
The transpiled code is wrapped in an object that exports as default at the bottom of the file. The name of this function is the name of the file itself.
--fix to fix path strings will only fix paths... it'll fix
my/dir but not
verbose is quite verbose ...Just ask Vegeta.
My use case
Have an old project that uses the old defines/require functions to pull in dependencies. Want to upgrade this without having to go through each file manually.