tarita

0.4.0 • Public • Published

tarita (たりた)

Convert Require.js define to EcmaScript imports

Dependency Status Build Status codecov.io

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 tarita

Please 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.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.

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.0

Version history

  • v0.4.0 (2016-01-28)
    • Do not break the existing structure outside define statement
  • 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 nyc for code coverage
    • Anything that was originally return should be the export default
  • v0.1.0 (2016-01-25)
    • Initial conversion ability from a define to import and export default

License

Copyright (c) Juga Paazmaya paazmaya@yahoo.com

Licensed under the MIT license.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.4.0
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.4.0
    0
  • 0.3.0
    1
  • 0.2.0
    1
  • 0.1.0
    1

Package Sidebar

Install

npm i tarita

Weekly Downloads

3

Version

0.4.0

License

MIT

Last publish

Collaborators

  • paazmaya