From 5856298798ac4e030d92d7329751df0328f40d0a Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Wed, 3 May 2017 10:45:45 -0700 Subject: [PATCH] test: cleanup rxjs custom build The latest rxjs release works with closure compiler out of the box. We no longer need to compile our own. Also put closure options into a file rather than using a shell script. --- integration/.gitignore | 1 - integration/README.md | 8 +-- integration/build_rxjs_es6.sh | 19 ------- integration/hello_world__closure/bundle.sh | 53 ------------------- integration/hello_world__closure/closure.conf | 30 +++++++++++ .../e2e/browser.config.json | 7 +-- integration/hello_world__closure/package.json | 11 ++-- .../hello_world__closure/src/index.html | 12 +++-- integration/run_tests.sh | 8 +-- integration/rxjs.tsconfig.json | 42 --------------- scripts/ci/build.sh | 10 ---- 11 files changed, 50 insertions(+), 151 deletions(-) delete mode 100755 integration/build_rxjs_es6.sh delete mode 100755 integration/hello_world__closure/bundle.sh create mode 100644 integration/hello_world__closure/closure.conf delete mode 100644 integration/rxjs.tsconfig.json diff --git a/integration/.gitignore b/integration/.gitignore index 58e631984a..636eb80144 100644 --- a/integration/.gitignore +++ b/integration/.gitignore @@ -1,4 +1,3 @@ -/rxjs/ built/ dist/ vendor/ diff --git a/integration/README.md b/integration/README.md index b189c02834..8036b35a48 100644 --- a/integration/README.md +++ b/integration/README.md @@ -32,13 +32,7 @@ Angular's `node_modules` is installed. ## Running integration tests -The first time you run the tests, you'll need some setup: - -```shell -$ ./integration/build_rxjs_es6.sh -``` - -Now you can iterate on the tests by keeping the dist folder up-to-date. +You can iterate on the tests by keeping the dist folder up-to-date. See the `package.json` of the test(s) you're debugging, to see which dist/ folders they install from. Then run the right `tsc --watch` command to keep those dist folders up-to-date, for example: diff --git a/integration/build_rxjs_es6.sh b/integration/build_rxjs_es6.sh deleted file mode 100755 index 2df8e9b2f1..0000000000 --- a/integration/build_rxjs_es6.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -# This script builds rxjs from source, with an ES6 target, and with tsickle turned on. -# We need to do this until we work with the RxJS team to get a distribution that works -# with Closure Compiler. -# Note that in nodejs, we still run the standard RxJS distribution. This one is only -# used for the bundle that targets a browser runtime. -# TODO(alexeagle): discuss with Jay Phelps once we have a recommendation - -set -e -o pipefail - -cd `dirname $0` - -rm -rf rxjs -git clone https://github.com/ReactiveX/rxjs.git --depth=200 -git -C rxjs/ checkout 5.0.3 -cp rxjs.tsconfig.json rxjs/ -TSC="node --max-old-space-size=3000 ../dist/tools/@angular/tsc-wrapped/src/main" -$TSC -p rxjs/rxjs.tsconfig.json diff --git a/integration/hello_world__closure/bundle.sh b/integration/hello_world__closure/bundle.sh deleted file mode 100755 index f8b7814693..0000000000 --- a/integration/hello_world__closure/bundle.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env bash - -# Build a folder using angular ES6 and the closure compiler - -set -e -o pipefail - -# The ES6 distro we built for rxjs works only in the browser, not in nodejs. -# Since we installed rxjs in node_modules for ngc to use, we have to point -# to the alternate distro when compiling with closure. -rm -rf vendor -mkdir vendor -cp -pr ../rxjs/dist/es6 vendor/rxjs - -CLOSURE_ARGS=( - "--language_in=ES6_STRICT" - "--language_out=ES5" - "--compilation_level=ADVANCED_OPTIMIZATIONS" - "--warning_level=QUIET" - "--js_output_file=dist/bundle.js" - "--create_source_map=%outname%.map" - "--variable_renaming_report=dist/variable_renaming_report" - "--property_renaming_report=dist/property_renaming_report" - - # Don't include ES6 polyfills - "--rewrite_polyfills=false" - - # List of path prefixes to be removed from ES6 & CommonJS modules. - "--js_module_root=node_modules/@angular/core" - "--js_module_root=node_modules/@angular/common" - "--js_module_root=node_modules/@angular/compiler" - "--js_module_root=node_modules/@angular/platform-browser" - "--js_module_root=vendor" - - # Uncomment for easier debugging - # "--formatting=PRETTY_PRINT" - - node_modules/@angular/core/src/testability/testability.externs.js - node_modules/zone.js/dist/zone.js - $(find -L vendor/rxjs -name *.js) - node_modules/@angular/core/@angular/core.js - node_modules/@angular/common/@angular/common.js - node_modules/@angular/compiler/@angular/compiler.js - node_modules/@angular/platform-browser/@angular/platform-browser.js - "built/src/*.js" - "--entry_point=./built/src/main" -) - -java -jar node_modules/google-closure-compiler/compiler.jar $(echo ${CLOSURE_ARGS[*]}) -# gzip on Travis doesn't have --keep option so copy the original file first -cp dist/bundle.js dist/bundle.tmp -gzip -f dist/bundle.js -mv dist/bundle.tmp dist/bundle.js -ls -alH dist/bundle* diff --git a/integration/hello_world__closure/closure.conf b/integration/hello_world__closure/closure.conf new file mode 100644 index 0000000000..8393a38b29 --- /dev/null +++ b/integration/hello_world__closure/closure.conf @@ -0,0 +1,30 @@ +--compilation_level=ADVANCED_OPTIMIZATIONS +--language_out=ES5 +--js_output_file=dist/bundle.js +--output_manifest=dist/manifest.MF +--variable_renaming_report=dist/variable_renaming_report +--property_renaming_report=dist/property_renaming_report +--create_source_map=%outname%.map + +--warning_level=QUIET +--dependency_mode=STRICT +--rewrite_polyfills=false + +node_modules/zone.js/dist/zone_externs.js + +--js node_modules/rxjs/**.js +--process_common_js_modules +--module_resolution=node + +node_modules/@angular/core/@angular/core.js +--js_module_root=node_modules/@angular/core +node_modules/@angular/core/src/testability/testability.externs.js + +node_modules/@angular/common/@angular/common.js +--js_module_root=node_modules/@angular/common + +node_modules/@angular/platform-browser/@angular/platform-browser.js +--js_module_root=node_modules/@angular/platform-browser + +--js built/**.js +--entry_point=built/src/main diff --git a/integration/hello_world__closure/e2e/browser.config.json b/integration/hello_world__closure/e2e/browser.config.json index 2886960214..dcdae63008 100644 --- a/integration/hello_world__closure/e2e/browser.config.json +++ b/integration/hello_world__closure/e2e/browser.config.json @@ -1,14 +1,15 @@ { "open": false, - "logLevel": "silent", + "logLevel": "silent", "port": 8080, "server": { "baseDir": "src", "routes": { - "/dist": "dist" + "/dist": "dist", + "/node_modules": "node_modules" }, "middleware": { "0": null } } -} +} \ No newline at end of file diff --git a/integration/hello_world__closure/package.json b/integration/hello_world__closure/package.json index 2119fa12b3..950b6857b2 100644 --- a/integration/hello_world__closure/package.json +++ b/integration/hello_world__closure/package.json @@ -11,10 +11,10 @@ "@angular/platform-browser": "file:../../dist/packages-dist/platform-browser", "@angular/platform-server": "file:../../dist/packages-dist/platform-server", "@angular/tsc-wrapped": "file:../../dist/tools/@angular/tsc-wrapped", - "google-closure-compiler": "20161201.0.0", - "rxjs": "file:../../node_modules/rxjs", + "google-closure-compiler": "20170409.0.0", + "rxjs": "5.3.1", "typescript": "2.1.6", - "zone.js": "0.7.6" + "zone.js": "0.8.6" }, "devDependencies": { "@types/jasmine": "2.5.41", @@ -23,9 +23,10 @@ "protractor": "file:../../node_modules/protractor" }, "scripts": { - "test": "ngc && ./bundle.sh && concurrently \"yarn run serve\" \"yarn run protractor\" --kill-others --success first", + "closure": "java -jar node_modules/google-closure-compiler/compiler.jar --flagfile closure.conf", + "test": "ngc && yarn run closure && concurrently \"yarn run serve\" \"yarn run protractor\" --kill-others --success first", "serve": "lite-server -c e2e/browser.config.json", "preprotractor": "tsc -p e2e", "protractor": "protractor e2e/protractor.config.js" } -} +} \ No newline at end of file diff --git a/integration/hello_world__closure/src/index.html b/integration/hello_world__closure/src/index.html index c2190cc743..ffbd2616e9 100644 --- a/integration/hello_world__closure/src/index.html +++ b/integration/hello_world__closure/src/index.html @@ -1,14 +1,18 @@ + Hello World - -Loading... - + + Loading... + + + - + + \ No newline at end of file diff --git a/integration/run_tests.sh b/integration/run_tests.sh index 1d37ff1f3c..53a64ad566 100755 --- a/integration/run_tests.sh +++ b/integration/run_tests.sh @@ -4,12 +4,6 @@ set -e -o pipefail cd `dirname $0` -if [ ! -d "rxjs/dist/es6" ]; then - echo "You must run build the ES2015 version of RxJS for some tests:" - echo "./integration/build_rxjs_es6.sh" - exit 1 -fi - # Workaround https://github.com/yarnpkg/yarn/issues/2165 # Yarn will cache file://dist URIs and not update Angular code readonly cache=.yarn_local_cache @@ -20,7 +14,7 @@ rm_cache mkdir $cache trap rm_cache EXIT -for testDir in $(ls | grep -v rxjs | grep -v node_modules) ; do +for testDir in $(ls | grep -v node_modules) ; do [[ -d "$testDir" ]] || continue echo "#################################" echo "Running integration test $testDir" diff --git a/integration/rxjs.tsconfig.json b/integration/rxjs.tsconfig.json deleted file mode 100644 index 5c8124d186..0000000000 --- a/integration/rxjs.tsconfig.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "angularCompilerOptions": { - "skipMetadataEmit": true, - "annotationsAs": "static fields", - "annotateForClosureCompiler": true - }, - - "compilerOptions": { - "types": [], - /** - * Remaining options are copied from - * https://github.com/ReactiveX/rxjs/blob/cba74135810a8e6bbe0b3c7732e8544b0869589e/tsconfig.json - * TODO(alexeagle): use "extends" instead when Angular is on TS 2.1 - */ - "removeComments": false, - "preserveConstEnums": true, - "sourceMap": true, - "declaration": true, - "noImplicitAny": true, - "noImplicitReturns": true, - "noImplicitThis": true, - "suppressImplicitAnyIndexErrors": true, - "moduleResolution": "node", - "module": "es2015", - "target": "es6", - "outDir": "dist/es6", - "lib": [ - "es5", - "es2015.iterable", - "es2015.collection", - "es2015.promise", - "dom" - ] - }, - "formatCodeOptions": { - "indentSize": 2, - "tabSize": 2 - }, - "files": [ - "src/Rx.ts" - ] -} diff --git a/scripts/ci/build.sh b/scripts/ci/build.sh index bf6279296b..7168cbef35 100755 --- a/scripts/ci/build.sh +++ b/scripts/ci/build.sh @@ -37,16 +37,6 @@ travisFoldStart "tsc a bunch of useless stuff" travisFoldEnd "tsc a bunch of useless stuff" -# Build integration tests -if [[ ${CI_MODE:-} == "e2e_2" ]]; then - travisFoldStart "build.integration" - cd "`dirname $0`/../../integration" - ./build_rxjs_es6.sh - cd - - travisFoldEnd "build.integration" -fi - - # Build angular.io if [[ ${CI_MODE:-} == "aio" ]]; then travisFoldStart "build.aio"