1 | # Build instructions
|
2 | defs is written in constlet style itself. There is an optional build step
|
3 | where it transpiles itself so that it can execute without the `--harmony`
|
4 | flag passed to node. There's another where Browserify bundles it up with
|
5 | its dependencies in a single JS file so that it can run in a browser.
|
6 |
|
7 | The git repository contains the original constlet style source code as well
|
8 | as the build scripts. It does not contain build artefacts (transpiled or
|
9 | bundled source).
|
10 |
|
11 | The build scripts populates the `build/es5` and `build/browser` directories.
|
12 | The NPM package contains a snapshot of the git repository at the time as
|
13 | well as `build/es5`. `package.json` refers to the transpiled version in
|
14 | `build/es5`, so there's no need to execute node with `--harmony` when
|
15 | running a `npm -g` installed `defs` from the command line or when doing a
|
16 | `require("defs")` of the same.
|
17 |
|
18 | If you clone the git repository then don't forget to also `npm install` the
|
19 | dependencies (see `package.json`).
|
20 |
|
21 | If you want to run defs in its original form (rather than transpiled), for
|
22 | instance if you're hacking on it, then just run the tool via `defs-harmony`
|
23 | (not a NPM exported binary but check the package root) or include it as a
|
24 | library via `require("defs.js/defs-main")`. This applies to a git
|
25 | clone just as well as the NPM package.
|
26 |
|
27 | `run-tests.js` is the test runner. It executes a fresh node/defs process
|
28 | for every test case. Run it on the original source via
|
29 | `node --harmony run-tests.js` - meaning the test-runner is executed in
|
30 | `--harmony` mode (because the runner is constlet style) and the child
|
31 | processes are too (because defs is constlet style). Run it on the
|
32 | transpiled source (i.e. `build/es5`) via `node run-tests.js es5` - meaning
|
33 | the test-runner and the child processes are executed in regular es5 (all
|
34 | have been transpiled). The tests are run automatically in the build scripts.
|
35 |
|
36 | To build, `cd build` then run `./build.sh` for self transpilation and
|
37 | `./bundle.sh` to create a (self transpiled) browser bundle using Browserify.
|
38 | Open up `build/browser/index.html` in your favorite browser to test the
|
39 | latter. `./clean.sh` removes the build artefacts.
|
40 |
|
41 | I use `prepare.sh` to prepare a release tarball for NPM publishing.
|
42 |
|
43 | Happy hacking!
|