tarita v0.4.0
tarita (たりた)
Convert Require.js define to EcmaScript imports
Parsing to AST happens with
espree and generating code back to JavaScript with
escodegen.
The name of the project is for honouring the legacy of Mrs Sonobe Hideo (園部 秀雄), who was the 15th head master of Jikishinkageryu Naginatajutsu (直心影流薙刀術), which is an ancient Japanese martial art, focusing the handling of a long pole like weapon called naginata. During her childhood she was called by the name Tarita, hence the name of this project.
Getting started
Install the tarita command line utility globally with npm.
Elevated privileges might be needed via sudo, depending on the platform. In most cases just:
npm install --global taritaPlease note that this tool requires the minimum Node.js
version to be 4.2.0, which is the Long Term Support (LTS) version.
Basic use case would be to have a single file containing:
define([
'jquery'
], function($) {
var SuperMan = {
power: $.fn.version
};
return SuperMan;
});Which would be converted with the command:
tarita input-file.jsThe contents of that file would be after the conversion:
import $ from 'jquery';
var SuperMan = { power: $.fn.version };
export default SuperMan;Please note that the given file will be overwritten, unless the --output-dir option is not used.
Command line options
The output of tarita --help pretty much covers all the options:
tarita [options] <file|directory>
-h, --help Help and usage instructions
-V, --version Version number
-v, --verbose Verbose output, will print which file is currently being processed
-o, --output-dir String Output directory, which by default overwrites the original files -
default: .
-M, --match String Regular expression for matching and filtering files - default: \.js$
-r, --recursive Recursively search matching files
Version 0.4.0Version history
v0.4.0(2016-01-28)- Do not break the existing structure outside
definestatement
- Do not break the existing structure outside
v0.3.0(2016-01-28)- Also convert cases when there are no dependencies or there is only dependencies
- Preserve comments
v0.2.0(2016-01-28)- Unit testing and automation for it. Using
nycfor code coverage - Anything that was originally
returnshould be theexport default
- Unit testing and automation for it. Using
v0.1.0(2016-01-25)- Initial conversion ability from a
definetoimportandexport default
- Initial conversion ability from a
License
Copyright (c) Juga Paazmaya paazmaya@yahoo.com
Licensed under the MIT license.