From ce781942079bcf080bc2229daf3d5ac366e5280d Mon Sep 17 00:00:00 2001 From: Justin Willis Date: Tue, 13 Sep 2016 16:46:00 -0500 Subject: [PATCH] feat(): add polyfill task * feat(): polyfills task * fix(): remove base option * fix(): minification and small polyfills * fix(): add readme and new file names * fix(): change task names * fix(): naming changes --- package.json | 2 ++ scripts/gulp/gulpfile.ts | 1 + scripts/gulp/tasks/polyfills.ts | 55 +++++++++++++++++++++++++++++++++ scripts/npm/polyfills.readme.md | 46 +++++++++++++++++++++++++++ 4 files changed, 104 insertions(+) create mode 100644 scripts/gulp/tasks/polyfills.ts create mode 100644 scripts/npm/polyfills.readme.md diff --git a/package.json b/package.json index 959a9dc0206..6f938c24d63 100644 --- a/package.json +++ b/package.json @@ -74,6 +74,7 @@ "gulp-strip-debug": "^1.1.0", "gulp-tslint": "^5.0.0", "gulp-typescript": "^2.13.6", + "gulp-uglify": "^2.0.0", "gulp-util": "^3.0.6", "gulp-watch": "^4.2.4", "html-entities": "^1.1.3", @@ -104,6 +105,7 @@ "tslint": "^3.15.1", "tslint-ionic-rules": "0.0.5", "typescript": "2.0.2", + "uglify": "^0.1.5", "vinyl": "^1.2.0", "webpack": "^2.1.0-beta.20", "webpack-dev-server": "^1.14.1", diff --git a/scripts/gulp/gulpfile.ts b/scripts/gulp/gulpfile.ts index 79a0f3b90d9..3aa366f14d4 100644 --- a/scripts/gulp/gulpfile.ts +++ b/scripts/gulp/gulpfile.ts @@ -6,4 +6,5 @@ import './tasks/lint'; import './tasks/release'; import './tasks/snapshot'; import './tasks/test'; +import './tasks/polyfills'; //import './tasks/theme'; diff --git a/scripts/gulp/tasks/polyfills.ts b/scripts/gulp/tasks/polyfills.ts new file mode 100644 index 00000000000..47bd75bfff9 --- /dev/null +++ b/scripts/gulp/tasks/polyfills.ts @@ -0,0 +1,55 @@ +import { task, src, dest } from 'gulp'; +const concat = require('gulp-concat'); +const uglify = require('gulp-uglify'); + +task('polyfill', ['polyfill.modern', 'polyfill.all', 'polyfill.ng', 'polyfill.copy-readme']); + +task('polyfill.modern', (done) => { + return src([ + 'node_modules/zone.js/dist/zone.min.js', + 'node_modules/zone.js/dist/proxy.min.js', + 'node_modules/core-js/es6/array.js', + 'node_modules/core-js/es6/date.js', + 'node_modules/core-js/es6/function.js', + 'node_modules/core-js/es6/map.js', + 'node_modules/core-js/es6/number.js', + 'node_modules/core-js/es6/object.js', + 'node_modules/core-js/es6/parse-float.js', + 'node_modules/core-js/es6/parse-int.js', + 'node_modules/core-js/es6/promise.js', + 'node_modules/core-js/es6/set.js', + 'node_modules/core-js/es6/string.js', + 'node_modules/core-js/es7/reflect.js' + ]) + .pipe(concat('polyfills.modern.js')) + .pipe(uglify()) + .pipe(dest('dist/ionic-angular/polyfills/'), done); +}); + +task('polyfill.all', (done) => { + return src([ + 'node_modules/zone.js/dist/zone.min.js', + 'node_modules/zone.js/dist/proxy.min.js', + 'node_modules/core-js/es6/index.js', + 'node_modules/core-js/es7/reflect.js' + ]) + .pipe(concat('polyfills.js')) + .pipe(uglify()) + .pipe(dest('dist/ionic-angular/polyfills/'), done); +}); + +task('polyfill.ng', (done) => { + return src([ + 'node_modules/zone.js/dist/zone.min.js', + 'node_modules/zone.js/dist/proxy.min.js', + 'node_modules/core-js/es7/reflect.js' + ]) + .pipe(concat('polyfills.ng.js')) + .pipe(uglify()) + .pipe(dest('dist/ionic-angular/polyfills/'), done); +}); + +task('polyfill.copy-readme', (done) => { + return src('scripts/npm/polyfills.readme.md') + .pipe(dest('dist/ionic-angular/polyfills/README.md'), done); +}); diff --git a/scripts/npm/polyfills.readme.md b/scripts/npm/polyfills.readme.md new file mode 100644 index 00000000000..bf4f1187288 --- /dev/null +++ b/scripts/npm/polyfills.readme.md @@ -0,0 +1,46 @@ +## polyfills.js +Contains all polyfills needed to work on the largest range of devices. This is the default polyfill. + +##### Targets: +- Android 4.4.2 and above +- iOS back to iOS 8 + +##### Includes: +- All ES6 features +- zone.js +- ES7 reflection + + +## polyfills.modern.js +A limited of set of polyfills to work on more modern browsers. This file limits the number of ES6 polyfills which are already natively included in modern browsers. + +##### Targets: +- Android 5.0 and above +- iOS 9 and above + +##### Includes: +- zone.js +- ES7 reflection, +- ES6 polyfills, except for: +new regexp features, +math features, +symbols, +typed arrays, +weak maps / weak sets + + +## polyfills.ng.js +Only the required polyfill for Angular 2. This does not come with any ES6 polyfills. Note that all polyfill files listed here included the required polyfills for Angular 2 to work correctly. + +##### Targets: +- Android 5.0 and above +- iOS 10 and above + +##### Includes: +- zone.js +- ES7 reflection + + +## ECMAScript 6 Compatibility + +To easily judge which polyfill you may need you can check this [ES6 support table](https://kangax.github.io/compat-table/es6/).