1.1.0 • Published 5 years ago

requiretoimports v1.1.0

Weekly downloads
3
License
ISC
Repository
github
Last release
5 years ago

Require To Imports

RTI

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: Define Array

OR

with a bunch of require declarations Define Array

These transpile into:

Define Array

AND

Define Array

Usage and Commands

Demo

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.