diff --git a/README.md b/README.md index 0edf20435c..f7d6cada9a 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ The **GABA** engine is a collection of platform-agnostic modules for creating se - [Subscription](#subscription) - [Composition](#composition) - [TypeScript](#why-typescript) +- [Linking](#linking-during-development) - [API documentation](#api-documentation) - [License](#license) @@ -39,7 +40,7 @@ The **GABA** engine is a collection of platform-agnostic modules for creating se new NetworkStatusController(), new TokenRatesController() ]); - + datamodel.subscribe((state) => {/* data model has changed */}); ``` @@ -305,6 +306,22 @@ TypeScript automatically transpiles the latest ECMAScript language features to a All of these features of a statically-typed language like TypeScript combine to form codebases consisting of strict contractural relationships between every module in an application. Changes are less intimidating since unnoticed side effects are difficult to introduce, documentation can be generated with less verbose syntax (TSDoc is JSDoc without the types since it can infer them), editors provide autocompletion of both public module members and of local and NPM dependencies, and an upgrade to TypeScript can be incremental as demonstrated in this PR. +## Linking during development + +Linking GABA into other projects involves a special NPM command to ensure that dependencies are not duplicated. This is because GABA ships modules that are transpiled but not bundled, and [NPM does not deduplicate](https://github.com/npm/npm/issues/7742) linked dependency trees. + +1. Link GABA. + + ```sh + $ npm run build:link + ``` + +2. Link into other projects. + + ```sh + $ npm link gaba + ``` + ## API documentation API documentation is auto-generated for the GABA package on every commit to the `master` branch. diff --git a/package.json b/package.json index 51c35e758e..b9d8bb89f5 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,9 @@ "lint": "tslint src/**/*.ts", "test": "jest --coverage", "format": "prettier **/*.ts --write --ignore-path=.gitignore", - "build": "tsc && cp package.json dist/.", + "build": "rm -rf dist && tsc && cp package.json dist/.", + "build:watch": "npm run build && tsc -w", + "build:link": "npm run build && cd dist && npm link && rm -rf node_modules && cd ..", "doc": "typedoc src/ && touch docs/.nojekyll" }, "jest": {