UNPKG

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