Install all dependencies and build/test the current version with these commands:
npm i
npm run bt
To run all tests and required builds, use the shorthand command bt
to build and test all assets. bt
is first running a NodeJS test and afterwards bundling the browser assets to execute the browser tests on them.
This library is built with tsc
and webpack
and outputs the following assets:
/dist
folder - for further development in a non-browser environment (e.g. NodeJS/TypeScript context)tsserval.js
- the uncompressed browser javascript sourcetsserval.min.js
- the compressed browser javascript source- Additional files (map files, licenses, ...)
Various build scripts are available over the npm run
commands:
bt
builds all assets and runs all tests in a smart order (without doing too many things if tests break)build
compiles all sources, tests to /dist and packs them browser-friendly to /lib-webbuild:node
compiles all TypeScript sources viatsc
from /src to /dist and checks circular dependencies on /distbuild:test
compiles all TypeScript tests viatsc
from /test to /dist-testbundle
creates browser-friendly assetsbundle:lib
bundles compiled distribution files to a browser-friendly asset viawebpack
from /dist to /lib-web (tsserval.js)bundle:min
bundles compiled distribution files to a compressed/minified browser-friendly asset viawebpack
from /dist to /lib-web (tsserval.min.js)bundle:test
bundles compiled test files to a browser-friendly form viawebpack
from /dist-test to /lib-web
build:ci
is meant as build command for the pipeline and effectively runsbuild
with a step in between, which replaces the runtime version informations in the respective file
Tests are written in TypeScript and executed in NodeJS and browser environments.
- NodeJS tests are executed with the
mocha
testrunner andnode-ts
as TypeScript environment. Thus, running the NodeJS tests do not require abuild
step asnode-ts
is coping with the TypeScript compilation internally. - Browser tests are executed with
bt-runner
which useschromedriver
to test the bundled assets in compressed and uncompressed variants within the browser environment. The browser tests do not automaticallybundle
new builds, thus a browser build must be triggered before the browser tests.
Various test scripts are available over the npm run
commands:
bt
builds all assets and runs all tests in a smart order (without doing too many things if tests break)test
runs all tests, first NodeJS then browser environmenttest:node
runs NodeJS tests withnode-ts
test:web
runs the tests on a browser environment withbt-runner
test:server
runs a keep-alive version ofbt-runner
which can be used for debugging
Because of the files
property within the package.json
, only the respective build assets are published to the package registry. A license check is done before publishing it to the respective package registry.
ts-serval only has only one runtime dependency so far, which is reflect-metadata
to extract the metadata information out of the TypeScript compilation process and make it accessible in the runtime context.