JS Import Compiler optimizes JavaScript by inlining recursively JavaScript files referenced by $import function
JavaScript
Switch branches/tags
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
demo
lib
test
.gitignore
.jscsrc
.jshintrc
.travis.yml
Gruntfile.js
README.md
jsic
jsic-module.js
jsic.js
package.json

README.md

JS Import Compiler

JS Import Compiler is a node.js application that looks for $import calls recursively in the source JavaScript file and resolves them in the destination file the same way as LESS/SCSS preprocessors resolve @import rule in the output CSS.

Why not AMD?

  • JSCS gives a way to reduce the number of HTTP requests by combining all scripts into a single one, what increases the application performance
  • Being a build tool JSCS doesn't require any additional JavaScript on client-side

Usage

Define dependencies in your code:

src/main.js

var foo = $import( "./Form/Input/Tel" );

Create the dependency source:

src/Form/Input/Tel.js

function() {
    return {
          prop: "",
          method: function(){}
    }
}

Run the compiler:

node jsic.js src/main.js build/mail.js

Examine the combined file:

build/main.js

var foo = function() {
    return {
          prop: "",
          method: function(){}
    }
};

Linter compatibility

In order to have keep dependency source in in valid syntax from a linter prospective you can assign its body to module.exports, which is ignored by the compiler

/**
* The banner will be ignored by compiler
*/
module.exports = function() {
    return {
          prop: "",
          method: function(){}
    }
};

JSIC as a grunt task

Please find instructions at https://github.com/dsheiko/grunt-jsic Analytics