AMD2CMD
transform AMD or CommonJS inspired by require.js to CommonJS.
Transform What
before(AMD):
;
transform after(CommonJS):
var dep1 = ;var dep2OtherName = ;moduleexports = dep1 + dep2OtherName;
- transform
define(['dep1', 'dep2'], function() {});
torequire('dep1');require('dep2');
- transform
define(function(){return statements;})
tomodule.exports = statements;
- transform
require('obj/xxx')
torequire('../obj/xxx')
So, Notice this tool can not transform all require.js features.
Usage
cli
First, install amd2cmd:
npm install -g amd2cmd
Second, cd your project, and exec cmd:
amd2cmd --in=src/scripts/**/*.js --out=build/scripts --basedir=src/scripts
use with node.js
First, install amd2cmd:
npm install --save amd2cmd
Then, you can use amd2cmd like this:
; ;
or like this:
; const cmdCode = ; console;/* print:var dep1 = require('dep1');var dep2OtherName = require('dep2');module.exports = dep1 + dep2OtherName;*/
use with gulp
; gulp;
scripts
Build the project shell:
$ npm run build
Test the project shell:
$ npm run test
Test the project with coverage result:
$ npm run coverage
Generate JavaScript API doc:
$ npm run doc