Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Mar 31, 2023. It is now read-only.

dweng0/requiretoimports

Repository files navigation

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.

About

Transform files that use old require AMD into new es6 Import UMD

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published