Convert Require.js define to EcmaScript imports
Parsing to Abstract Syntax Tree (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.
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 tarita
Please note that the minimum supported version of Node.js is 14.15.0
, which is the active 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.js
The 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.
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.5.0
"A Beginner's Guide to Open Source: The Best Advice for Making your First Contribution".
Also there is a blog post about "45 Github Issues Dos and Don’ts".
Linting is done with ESLint and can be executed with npm run lint
.
There should be no errors appearing after any JavaScript file changes.
Please note that any features or changed will not be merged without working unit tests.
Unit tests are written with tape
and can be executed with npm test
.
Code coverage is inspected with nyc
and
can be executed with npm run coverage
after running npm test
.
Please make sure it is over 90% at all times.
Copyright (c) Juga Paazmaya [email protected]
Licensed under the MIT license.