-
Notifications
You must be signed in to change notification settings - Fork 27.3k
chore: track size of a "Hello world" app built with WebPack #6434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
pkozlowski-opensource
wants to merge
1
commit into
angular:master
from
pkozlowski-opensource:hello_world_size_monitor
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,7 +42,7 @@ if (cliArgs.projects) { | |
|
|
||
| // --projects=angular2,angular2_material => {angular2: true, angular2_material: true} | ||
| var allProjects = | ||
| 'angular1_router,angular2,angular2_material,benchmarks,benchmarks_external,benchpress,playground,bundle_deps'; | ||
| 'angular1_router,angular2,angular2_material,benchmarks,benchmarks_external,benchpress,playground,payload_tests,bundle_deps'; | ||
| var cliArgsProjects = (cliArgs.projects || allProjects) | ||
| .split(',') | ||
| .reduce((map, projectName) => { | ||
|
|
@@ -168,6 +168,20 @@ var BENCHPRESS_BUNDLE_CONFIG = { | |
| dest: CONFIG.dest.bundles.benchpress | ||
| }; | ||
|
|
||
| var PAYLOAD_TESTS_CONFIG = { | ||
| ts: { | ||
| sizeLimits: {'uncompressed': 550 * 1024, 'gzip level=9': 120 * 1024}, | ||
| webpack: { | ||
| cases: ['hello_world'], | ||
| bundleName: 'app-bundle-deps.min.js', | ||
| dist: function(caseName) { | ||
| return path.join(__dirname, CONFIG.dest.js.prod.es5, 'payload_tests', caseName, | ||
| 'ts/webpack'); | ||
| } | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| // ------------ | ||
| // clean | ||
|
|
||
|
|
@@ -638,7 +652,7 @@ gulp.task('test.unit.dart', function(done) { | |
| // This test will fail if the size of our hello_world app goes beyond one of | ||
| // these values when compressed at the specified level. | ||
| // Measure in bytes. | ||
| var _DART_PAYLOAD_SIZE_LIMITS = {'uncompressed': 320 * 1024, 'gzip level=6': 90 * 1024}; | ||
| var _DART_PAYLOAD_SIZE_LIMITS = {'uncompressed': 320 * 1024, 'gzip level=9': 90 * 1024}; | ||
| gulp.task('test.payload.dart/ci', function(done) { | ||
| runSequence('build/packages.dart', '!pubget.payload.dart', '!pubbuild.payload.dart', | ||
| '!checkAndReport.payload.dart', done); | ||
|
|
@@ -658,6 +672,64 @@ gulp.task('!checkAndReport.payload.dart', function() { | |
| {failConditions: _DART_PAYLOAD_SIZE_LIMITS, prefix: 'hello_world'}); | ||
| }); | ||
|
|
||
| // JS payload size tracking | ||
| gulp.task('test.payload.js/ci', function(done) { | ||
| runSequence('build.payload.js', '!checkAndReport.payload.js', sequenceComplete(done)); | ||
| }); | ||
|
|
||
| gulp.task('build.payload.js', ['build.js.prod'], | ||
| function(done) { runSequence('!build.payload.js.webpack', sequenceComplete(done)); }); | ||
|
|
||
| gulp.task('!build.payload.js.webpack', function() { | ||
| var q = require('q'); | ||
| var webpack = q.denodeify(require('webpack')); | ||
| var concat = require('gulp-concat'); | ||
| var uglify = require('gulp-uglify'); | ||
|
|
||
| var ES5_PROD_ROOT = __dirname + '/' + CONFIG.dest.js.prod.es5; | ||
|
|
||
| return q.all(PAYLOAD_TESTS_CONFIG.ts.webpack.cases.map(function(caseName) { | ||
| var CASE_PATH = PAYLOAD_TESTS_CONFIG.ts.webpack.dist(caseName); | ||
|
|
||
| return webpack({ | ||
| // bundle app + framework | ||
| entry: CASE_PATH + '/index.js', | ||
| output: {path: CASE_PATH, filename: "app-bundle.js"}, | ||
| resolve: { | ||
| extensions: ['', '.js'], | ||
| packageAlias: '', // option added to ignore "broken" package.json in our dist folder | ||
| root: [ES5_PROD_ROOT] | ||
| } | ||
| }) | ||
| .then(function() { // pad bundle with mandatory dependencies | ||
| return new Promise(function(resolve, reject) { | ||
| gulp.src([ | ||
| 'node_modules/zone.js/dist/zone-microtask.js', | ||
| 'node_modules/zone.js/dist/long-stack-trace-zone.js', | ||
| 'node_modules/reflect-metadata/Reflect.js', | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you intentionally not using the angular2-polyfills.js?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeh, just to avoid building all the bundles. |
||
| CASE_PATH + '/app-bundle.js' | ||
| ]) | ||
| .pipe(concat(PAYLOAD_TESTS_CONFIG.ts.webpack.bundleName)) | ||
| .pipe(uglify()) | ||
| .pipe(gulp.dest(CASE_PATH)) | ||
| .on('end', resolve) | ||
| .on('error', reject); | ||
| }); | ||
| }); | ||
| })); | ||
| }); | ||
|
|
||
| gulp.task('!checkAndReport.payload.js', function() { | ||
| var reportSize = require('./tools/analytics/reportsize'); | ||
| var webPackConf = PAYLOAD_TESTS_CONFIG.ts.webpack; | ||
|
|
||
| return webPackConf.cases.reduce(function(sizeReportingStreams, caseName) { | ||
| sizeReportingStreams.add( | ||
| reportSize(webPackConf.dist(caseName) + '/' + webPackConf.bundleName, | ||
| {failConditions: PAYLOAD_TESTS_CONFIG.ts.sizeLimits, prefix: caseName})) | ||
| }, merge2()); | ||
| }); | ||
|
|
||
| gulp.task('watch.dart.dev', function(done) { | ||
| runSequence('build/tree.dart', 'build/pure-packages.dart', '!build/pubget.angular2.dart', | ||
| '!build/change_detect.dart', '!build/remove-pub-symlinks', 'build.dart.material.css', | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <!doctype html> | ||
| <html> | ||
| <title>Angular 2.0 Hello World payload test</title> | ||
| <body> | ||
| <hello-app> | ||
| Loading... | ||
| </hello-app> | ||
| <script src="app-bundle-deps.min.js"></script> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import {Component} from 'angular2/core'; | ||
| import {bootstrap} from 'angular2/bootstrap'; | ||
|
|
||
| @Component({ | ||
| selector: 'hello-app', | ||
| template: ` | ||
| <h1>Hello, {{name}}!</h1> | ||
| <label> Say hello to: <input [value]="name" (input)="name = $event.target.value"></label> | ||
| ` | ||
| }) | ||
| export class HelloCmp { | ||
| name = 'World'; | ||
| } | ||
|
|
||
| bootstrap(HelloCmp); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of putting it in our main gulpfile.js, can the webpack code be moved closer to the application itself? This way one doesn't need to look in multiple places to figure out how to package an app for production.