Improves build script performance by: * using built-ins wherever possible (e.g. string splitting) * eliminating redundant code * using absolute (to $KEYMAN_ROOT) rather than relative paths to avoid realpath * removing unnecessary `npm run` calls BEFORE | AFTER -------------------------------|---------------------- time ./core/build.sh --help | real 0m2.116s | real 0m0.874s user 0m0.578s | user 0m0.198s sys 0m0.984s | sys 0m0.289s -------------------------------|---------------------- time ./web/build.sh --help | real 0m3.523s | real 0m0.757s user 0m1.166s | user 0m0.320s sys 0m2.273s | sys 0m0.455s -------------------------------|---------------------- time ./web/build.sh -d | real 1m34.750s | real 0m59.974s user 0m9.721s | user 0m6.284s sys 0m19.652s | sys 0m13.202s @keymanapp-test-bot skip |
||
|---|---|---|
| .. | ||
| docs | ||
| testing | ||
| unit_tests | ||
| .build-builder | ||
| .gitignore | ||
| browser.tsconfig.json | ||
| build.sh | ||
| embedded_worker.d.ts | ||
| index.d.ts | ||
| index.ts | ||
| node-defaultWorker.ts | ||
| package.json | ||
| promise-store.ts | ||
| README.md | ||
| tsconfig.json | ||
| virtualizedWorker.ts | ||
| web-defaultWorker.ts | ||
| worker-interface.d.ts | ||
Language Modelling Layer (LMLayer)
Provide predictions and corrections while you type!
See Worker Communication Protocol for a semi-formal specification on how the Worker and the main thread communicate.
System dependencies
You will need Bash and Node.js >= 10.0.
Build
Run build.sh. This will also automatically install dependencies with npm.
./build.sh
Two-stage compilation process
Since the primary LMLayer code runs within a Web Worker, build.sh compiles the
LMLayer in two stages:
-
Compile the inner worker code
- Compile the TypeScript sources for only the Worker code.
- Wrap the Worker code as
embedded_worker.js
-
Compile the top-level code
- Include
embedded_worker.jsverbatim using a TypeScript directive. - Compile the top-level TypeScript code.
- Unwrap the Worker code at runtime.
- Include
Test
This will run both headless unit tests, and in-browser unit tests and integration tests:
./build.sh -test
Test-Driven Development
I like to use entr to automatically build and re-run the unit tests anytime I change a source code file. Here's the command I run in separate window:
git ls-files | entr -c ./build.sh -tdd
Importantly, ./build.sh -tdd skips running the in-browser tests, and skips
downloading/updating npm dependencies.