@@ -51,6 +51,7 @@ TSCONFIG=./modules/tsconfig.json
5151echo " ====== (all)COMPILING: \$ (npm bin)/tsc -p ${TSCONFIG} ====="
5252# compile ts code
5353TSC=" node --max-old-space-size=3000 dist/tools/@angular/tsc-wrapped/src/main"
54+ UGLIFYJS=` pwd` /node_modules/.bin/uglifyjs
5455$TSC -p modules/tsconfig.json
5556
5657rm -rf ./dist/packages-dist
@@ -68,56 +69,61 @@ for PACKAGE in \
6869 upgrade \
6970 compiler-cli
7071do
71- SRCDIR=./modules/@angular/ ${PACKAGE}
72- DESTDIR=./dist/packages-dist /${PACKAGE}
73- UMD_ES6_PATH =${DESTDIR} /esm/ ${PACKAGE} .umd.js
72+ PWD= ` pwd `
73+ SRCDIR= ${PWD} /modules/@angular /${PACKAGE}
74+ DESTDIR =${PWD} /dist/packages-dist/ ${PACKAGE}
7475 UMD_ES5_PATH=${DESTDIR} /bundles/${PACKAGE} .umd.js
76+ UMD_TESTING_ES5_PATH=${DESTDIR} /bundles/${PACKAGE} -testing.umd.js
7577 UMD_ES5_MIN_PATH=${DESTDIR} /bundles/${PACKAGE} .umd.min.js
78+ LICENSE_BANNER=${PWD} /modules/@angular/license-banner.txt
7679
77- echo " ====== COMPILING: ${TSC} -p ${SRCDIR} /tsconfig-es5 .json ====="
78- $TSC -p ${SRCDIR} /tsconfig-es5 .json
80+ echo " ====== COMPILING: ${TSC} -p ${SRCDIR} /tsconfig.json ====="
81+ $TSC -p ${SRCDIR} /tsconfig.json
7982
8083 cp ${SRCDIR} /package.json ${DESTDIR} /
8184
85+ if [[ -e ${SRCDIR} /tsconfig-testing.json ]]; then
86+ echo " ====== COMPILING TESTING: ${TSC} -p ${SRCDIR} /tsconfig-testing.json"
87+ $TSC -p ${SRCDIR} /tsconfig-testing.json
88+ fi
8289
8390 echo " ====== TSC 1.8 d.ts compat for ${DESTDIR} ====="
8491 # safely strips 'readonly' specifier from d.ts files to make them compatible with tsc 1.8
8592 if [ " $( uname) " == " Darwin" ]; then
86- find ${DESTDIR} -type f -name ' *.d.ts' -print0 | xargs -0 sed -i ' ' -e ' s/\(^ *(static |private )*\)*readonly */\1/g'
87- find ${DESTDIR} -type f -name ' *.d.ts' -print0 | xargs -0 sed -i ' ' -E ' s/^( +)abstract ([[:alnum:]]+\:)/\1\2/g'
93+ find ${DESTDIR} -type f -name ' *.d.ts' -print0 | xargs -0 sed -i ' ' -e ' s/\(^ *(static |private )*\)*readonly */\1/g'
94+ find ${DESTDIR} -type f -name ' *.d.ts' -print0 | xargs -0 sed -i ' ' -e ' s/\/\/\/ <reference types="node" \/>//g'
95+ find ${DESTDIR} -type f -name ' *.d.ts' -print0 | xargs -0 sed -i ' ' -E ' s/^( +)abstract ([[:alnum:]]+\:)/\1\2/g'
8896 else
8997 find ${DESTDIR} -type f -name ' *.d.ts' -print0 | xargs -0 sed -i -e ' s/\(^ *(static |private )*\)*readonly */\1/g'
98+ find ${DESTDIR} -type f -name ' *.d.ts' -print0 | xargs -0 sed -i -e ' s/\/\/\/ <reference types="node" \/>//g'
9099 find ${DESTDIR} -type f -name ' *.d.ts' -print0 | xargs -0 sed -i -E ' s/^( +)abstract ([[:alnum:]]+\:)/\1\2/g'
91100 fi
92101
93102 if [[ ${PACKAGE} != compiler-cli ]]; then
94103
95- echo " ====== (esm)COMPILING: $TSC -p ${SRCDIR} /tsconfig-es2015.json ====="
96- $TSC -p ${SRCDIR} /tsconfig-es2015.json
97-
98104 echo " ====== BUNDLING: ${SRCDIR} ====="
99105 mkdir ${DESTDIR} /bundles
100106
101107 (
102108 cd ${SRCDIR}
103- echo " ... " # here just to have grep match something and not exit with 1
109+ echo " ====== Rollup ${PACKAGE} index "
104110 ../../../node_modules/.bin/rollup -c rollup.config.js
111+ cat ${LICENSE_BANNER} > ${UMD_ES5_PATH} .tmp
112+ cat ${UMD_ES5_PATH} >> ${UMD_ES5_PATH} .tmp
113+ mv ${UMD_ES5_PATH} .tmp ${UMD_ES5_PATH}
114+ $UGLIFYJS -c --screw-ie8 --comments -o ${UMD_ES5_MIN_PATH} ${UMD_ES5_PATH}
115+
116+
117+ if [[ -e rollup-testing.config.js ]]; then
118+ echo " ====== Rollup ${PACKAGE} testing"
119+ ../../../node_modules/.bin/rollup -c rollup-testing.config.js
120+ echo " {\" main\" : \" ../bundles/${PACKAGE} -testing.umd.js\" }" > ${DESTDIR} /testing/package.json
121+ cat ${LICENSE_BANNER} > ${UMD_TESTING_ES5_PATH} .tmp
122+ cat ${UMD_TESTING_ES5_PATH} >> ${UMD_TESTING_ES5_PATH} .tmp
123+ mv ${UMD_TESTING_ES5_PATH} .tmp ${UMD_TESTING_ES5_PATH}
124+ fi
105125 ) 2>&1 | grep -v " as external dependency"
106126
107- $( npm bin) /tsc \
108- --out ${UMD_ES5_PATH} \
109- --target es5 \
110- --lib " es6,dom" \
111- --allowJs \
112- ${UMD_ES6_PATH}
113-
114- rm ${UMD_ES6_PATH}
115-
116- cat ./modules/@angular/license-banner.txt > ${UMD_ES5_PATH} .tmp
117- cat ${UMD_ES5_PATH} >> ${UMD_ES5_PATH} .tmp
118- mv ${UMD_ES5_PATH} .tmp ${UMD_ES5_PATH}
119-
120- $( npm bin) /uglifyjs -c --screw-ie8 -o ${UMD_ES5_MIN_PATH} ${UMD_ES5_PATH}
121127 fi
122128done
123129
0 commit comments