build.sh (1031B)
1 #!/bin/sh 2 set -euo pipefail 3 4 # Path to mach relative to /third_party/js/cfworker 5 MACH=$(realpath "../../../mach") 6 7 if [[ $(uname -a) == *MSYS* ]]; then 8 MACH="python ${MACH}" 9 fi 10 11 NODE="${MACH} node" 12 NPM="${MACH} npm" 13 14 # Delete empty vestigial directories. 15 rm -rf .changeset/ .github/ .vscode/ 16 17 # Patch typescript config to ensure we have LF endings. 18 patch tsconfig-base.json tsconfig-base.json.patch 19 20 cd packages/json-schema 21 22 # Install dependencies. 23 ${NPM} install --also=dev 24 25 # Compile TypeScript into JavaScript. 26 ${NPM} run build 27 28 # Install rollup and bundle into a single module. 29 ${NPM} install rollup@~2.67.x 30 ${NODE} node_modules/rollup/dist/bin/rollup \ 31 dist/index.js \ 32 --file json-schema.js \ 33 --format cjs 34 35 cd ../.. 36 37 # Patch the CommonJS module into a regular JS file and include a copyright notice. 38 patch packages/json-schema/json-schema.js json-schema.js.patch 39 awk -f exports.awk packages/json-schema/json-schema.js >json-schema.js 40 41 # Remove source files we no longer need. 42 rm -rf packages/ tsconfig-base.json