Code Monkey home page Code Monkey logo

amd2cmd's Introduction

AMD2CMD

transform AMD or CommonJS inspired by require.js to CommonJS.

NPM version Build Status Coverage Status Dependency Status

Transform What

before(AMD):

define(['dep1', 'dep2'], function(dep1, dep2OtherName) {
  return dep1 + dep2OtherName;
});

transform after(CommonJS):

var dep1 = require('dep1');
var dep2OtherName = require('dep2');
module.exports = dep1 + dep2OtherName;
  • transform define(['dep1', 'dep2'], function() {}); to require('dep1');require('dep2');
  • transform define(function(){return statements;}) to module.exports = statements;
  • transform require('obj/xxx') to require('../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:

import transform from 'amd2cmd';

transform(['src/scripts/**/*.js'], 'build/scripts', 'src/scripts')
.on('finish', function() {
  console.log('finish to transform amd code to cmd code');
});

scripts

Build the project shell:

 $ npm build

Test the project shell:

 $ npm test

Test the project with coverage result:

 $ npm coverage

Generate JavaScript API doc:

 $ npm esdoc

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.