requiretoimports
v1.1.0
Published
![alt text](./logo.png "Logo Title Text 1")
Downloads
6
Maintainers
Readme
Require To Imports
Take your old files that use AMD require.
and magically ~~break them.~~ turn them into files that use es6 imports!
Code style
The transpiler focuses on code written using the define()
function, either with an array of paths as the first argument:
OR
with a bunch of require declarations
These transpile into:
AND
Usage and Commands
commands
typical usage:
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
the 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
Gotchas
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.
use --fix
to fix path strings will only fix paths... it'll fix my/dir
but not underscore
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.