@@ -42,7 +42,7 @@ if (cliArgs.projects) {
4242
4343// --projects=angular2,angular2_material => {angular2: true, angular2_material: true}
4444var allProjects =
45- 'angular1_router,angular2,angular2_material,benchmarks,benchmarks_external,benchpress,playground,bundle_deps' ;
45+ 'angular1_router,angular2,angular2_material,benchmarks,benchmarks_external,benchpress,playground,payload_tests, bundle_deps' ;
4646var cliArgsProjects = ( cliArgs . projects || allProjects )
4747 . split ( ',' )
4848 . reduce ( ( map , projectName ) => {
@@ -168,6 +168,20 @@ var BENCHPRESS_BUNDLE_CONFIG = {
168168 dest : CONFIG . dest . bundles . benchpress
169169} ;
170170
171+ var PAYLOAD_TESTS_CONFIG = {
172+ ts : {
173+ sizeLimits : { 'uncompressed' : 550 * 1024 , 'gzip level=9' : 120 * 1024 } ,
174+ webpack : {
175+ cases : [ 'hello_world' ] ,
176+ bundleName : 'app-bundle-deps.min.js' ,
177+ dist : function ( caseName ) {
178+ return path . join ( __dirname , CONFIG . dest . js . prod . es5 , 'payload_tests' , caseName ,
179+ 'ts/webpack' ) ;
180+ }
181+ }
182+ }
183+ } ;
184+
171185// ------------
172186// clean
173187
@@ -638,7 +652,7 @@ gulp.task('test.unit.dart', function(done) {
638652// This test will fail if the size of our hello_world app goes beyond one of
639653// these values when compressed at the specified level.
640654// Measure in bytes.
641- var _DART_PAYLOAD_SIZE_LIMITS = { 'uncompressed' : 320 * 1024 , 'gzip level=6 ' : 90 * 1024 } ;
655+ var _DART_PAYLOAD_SIZE_LIMITS = { 'uncompressed' : 320 * 1024 , 'gzip level=9 ' : 90 * 1024 } ;
642656gulp . task ( 'test.payload.dart/ci' , function ( done ) {
643657 runSequence ( 'build/packages.dart' , '!pubget.payload.dart' , '!pubbuild.payload.dart' ,
644658 '!checkAndReport.payload.dart' , done ) ;
@@ -658,6 +672,64 @@ gulp.task('!checkAndReport.payload.dart', function() {
658672 { failConditions : _DART_PAYLOAD_SIZE_LIMITS , prefix : 'hello_world' } ) ;
659673} ) ;
660674
675+ // JS payload size tracking
676+ gulp . task ( 'test.payload.js/ci' , function ( done ) {
677+ runSequence ( 'build.payload.js' , '!checkAndReport.payload.js' , sequenceComplete ( done ) ) ;
678+ } ) ;
679+
680+ gulp . task ( 'build.payload.js' , [ 'build.js.prod' ] ,
681+ function ( done ) { runSequence ( '!build.payload.js.webpack' , sequenceComplete ( done ) ) ; } ) ;
682+
683+ gulp . task ( '!build.payload.js.webpack' , function ( ) {
684+ var q = require ( 'q' ) ;
685+ var webpack = q . denodeify ( require ( 'webpack' ) ) ;
686+ var concat = require ( 'gulp-concat' ) ;
687+ var uglify = require ( 'gulp-uglify' ) ;
688+
689+ var ES5_PROD_ROOT = __dirname + '/' + CONFIG . dest . js . prod . es5 ;
690+
691+ return q . all ( PAYLOAD_TESTS_CONFIG . ts . webpack . cases . map ( function ( caseName ) {
692+ var CASE_PATH = PAYLOAD_TESTS_CONFIG . ts . webpack . dist ( caseName ) ;
693+
694+ return webpack ( {
695+ // bundle app + framework
696+ entry : CASE_PATH + '/index.js' ,
697+ output : { path : CASE_PATH , filename : "app-bundle.js" } ,
698+ resolve : {
699+ extensions : [ '' , '.js' ] ,
700+ packageAlias : '' , // option added to ignore "broken" package.json in our dist folder
701+ root : [ ES5_PROD_ROOT ]
702+ }
703+ } )
704+ . then ( function ( ) { // pad bundle with mandatory dependencies
705+ return new Promise ( function ( resolve , reject ) {
706+ gulp . src ( [
707+ 'node_modules/zone.js/dist/zone-microtask.js' ,
708+ 'node_modules/zone.js/dist/long-stack-trace-zone.js' ,
709+ 'node_modules/reflect-metadata/Reflect.js' ,
710+ CASE_PATH + '/app-bundle.js'
711+ ] )
712+ . pipe ( concat ( PAYLOAD_TESTS_CONFIG . ts . webpack . bundleName ) )
713+ . pipe ( uglify ( ) )
714+ . pipe ( gulp . dest ( CASE_PATH ) )
715+ . on ( 'end' , resolve )
716+ . on ( 'error' , reject ) ;
717+ } ) ;
718+ } ) ;
719+ } ) ) ;
720+ } ) ;
721+
722+ gulp . task ( '!checkAndReport.payload.js' , function ( ) {
723+ var reportSize = require ( './tools/analytics/reportsize' ) ;
724+ var webPackConf = PAYLOAD_TESTS_CONFIG . ts . webpack ;
725+
726+ return webPackConf . cases . reduce ( function ( sizeReportingStreams , caseName ) {
727+ sizeReportingStreams . add (
728+ reportSize ( webPackConf . dist ( caseName ) + '/' + webPackConf . bundleName ,
729+ { failConditions : PAYLOAD_TESTS_CONFIG . ts . sizeLimits , prefix : caseName } ) )
730+ } , merge2 ( ) ) ;
731+ } ) ;
732+
661733gulp . task ( 'watch.dart.dev' , function ( done ) {
662734 runSequence ( 'build/tree.dart' , 'build/pure-packages.dart' , '!build/pubget.angular2.dart' ,
663735 '!build/change_detect.dart' , '!build/remove-pub-symlinks' , 'build.dart.material.css' ,
0 commit comments