Skip to content

0.3.x Building Inject From Source

Jakob Heuser edited this page Jul 20, 2012 · 1 revision

What You'll Need

Setting Up

  1. Install Node Download nodejs from the above link. The default installation should be fine for most people.
  2. Install npm Run the script command for npm available at the above link. The defaults should again be fine here.
  3. Install coffeescript globally (recommended) Once npm is installed, you can go to a terminal and enter the command sudo npm install -g coffee-script. This will install coffeescript globally for you. Coffeescript is the language inject is written in, and having access to the compiler makes things easier. This will also help if you'd like to make changes to the inject source code- Coffeescript provides functionality such as automatic file watching.
  4. In source directory, "npm install" doing npm install inside of the source directory ensures all the dependencies needed are available. They are placed in the node_modules directory.

Building

cake build can be used in order to build the project from source. Doing such enables advanced compilation options, including disabling the IE support if you don't find yourself needing to support past browsers.

--config-file           Load in a json file as config. Defaults to: null.

--project-name          Used in default config to specify final output for raw
                        and min "targets". Defaults to: "inject".

--project-version       Used in default config to add version folders to "out"
                        directory. Defaults to: "dev".

--temporary-directory   Where to save temporary files. Gets deleted after
                        build. Defaults to: "./tmp/".

--output-directory      Where to save compressed/compiled files. Defaults to:
                        "./artifacts/".

--with-ie               Add IE 6/7 support. Adds a localStorage and JSON shim
                        (by default, named: ie-localstorage-json-shim.js). Both
                        are required for lscache. Defaults to true.

--without-xd            Remove Porthole. Porthole is only used when requiring
                        files cross-domain. Defaults to false.

--without-json          Force JSON support to be dropped. Defaults to false.

--compilation-level     Level to compile output js to. If WHITESPACE_ONLY is
                        selected then pretty formatting is used. Defaults to
                        SIMPLE_OPTIMIZATIONS.

Verifying Tests

With a build of inject in the dev directory, you can run the tests from any browser. First, start the server:

node testserver.js

You can then run the tests by hitting http://localhost:4000/tests/index.html in your browser. We have a suite of tests that cover inject-specific integration, the CommonJS specification, and the AMD tests.