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:
/distfolder - 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:
btbuilds all assets and runs all tests in a smart order (without doing too many things if tests break)buildcompiles all sources, tests to /dist and packs them browser-friendly to /lib-webbuild:nodecompiles all TypeScript sources viatscfrom /src to /dist and checks circular dependencies on /distbuild:testcompiles all TypeScript tests viatscfrom /test to /dist-testbundlecreates browser-friendly assetsbundle:libbundles compiled distribution files to a browser-friendly asset viawebpackfrom /dist to /lib-web (tsserval.js)bundle:minbundles compiled distribution files to a compressed/minified browser-friendly asset viawebpackfrom /dist to /lib-web (tsserval.min.js)bundle:testbundles compiled test files to a browser-friendly form viawebpackfrom /dist-test to /lib-web
build:ciis meant as build command for the pipeline and effectively runsbuildwith 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
mochatestrunner andnode-tsas TypeScript environment. Thus, running the NodeJS tests do not require abuildstep asnode-tsis coping with the TypeScript compilation internally. - Browser tests are executed with
bt-runnerwhich useschromedriverto test the bundled assets in compressed and uncompressed variants within the browser environment. The browser tests do not automaticallybundlenew builds, thus a browser build must be triggered before the browser tests.
Various test scripts are available over the npm run commands:
btbuilds all assets and runs all tests in a smart order (without doing too many things if tests break)testruns all tests, first NodeJS then browser environmenttest:noderuns NodeJS tests withnode-tstest:webruns the tests on a browser environment withbt-runner
test:serverruns a keep-alive version ofbt-runnerwhich 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.