Alex Rickabaugh b10540a0b5 feat(service-worker): add helper script which will uninstall SW (#21863)
Service Workers can be tricky to work with in production, and often
it becomes necessary to deactivate an existing SW. This is trickier
than one might imagine - as long as clients on the old SW may exist
it is important to serve some script at the old SW URL. This commit
adds safety-worker.js to the published NPM package, which is useful
for that purpose. On install the SW unregisters itself which safely
and gradually allows older clients to update.

PR Close #21863
2018-01-30 11:43:03 -08:00

19 lines
560 B
Bash
Executable File

#!/bin/bash
set -u -e -o pipefail
BIN=$(cd .. && npm bin)
$BIN/tsc -p worker/tsconfig.json
$BIN/rollup -c worker/rollup-worker.config.js
$BIN/tsc -p cli/tsconfig.json
$BIN/rollup -c cli/rollup-cli.config.js
cp ./safety-worker.js ../../dist/packages-dist/service-worker/safety-worker.js
echo "#!/usr/bin/env node" > ../../dist/packages-dist/service-worker/ngsw-config.js
cat ../../dist/packages-dist/service-worker/ngsw-config-tmp.js >> ../../dist/packages-dist/service-worker/ngsw-config.js
rm ../../dist/packages-dist/service-worker/ngsw-config-tmp.js