Skip to content

Commit ce78194

Browse files
jgw96brandyscarney
authored andcommitted
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
1 parent f477aa2 commit ce78194

File tree

4 files changed

+104
-0
lines changed

4 files changed

+104
-0
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
"gulp-strip-debug": "^1.1.0",
7575
"gulp-tslint": "^5.0.0",
7676
"gulp-typescript": "^2.13.6",
77+
"gulp-uglify": "^2.0.0",
7778
"gulp-util": "^3.0.6",
7879
"gulp-watch": "^4.2.4",
7980
"html-entities": "^1.1.3",
@@ -104,6 +105,7 @@
104105
"tslint": "^3.15.1",
105106
"tslint-ionic-rules": "0.0.5",
106107
"typescript": "2.0.2",
108+
"uglify": "^0.1.5",
107109
"vinyl": "^1.2.0",
108110
"webpack": "^2.1.0-beta.20",
109111
"webpack-dev-server": "^1.14.1",

scripts/gulp/gulpfile.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ import './tasks/lint';
66
import './tasks/release';
77
import './tasks/snapshot';
88
import './tasks/test';
9+
import './tasks/polyfills';
910
//import './tasks/theme';

scripts/gulp/tasks/polyfills.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { task, src, dest } from 'gulp';
2+
const concat = require('gulp-concat');
3+
const uglify = require('gulp-uglify');
4+
5+
task('polyfill', ['polyfill.modern', 'polyfill.all', 'polyfill.ng', 'polyfill.copy-readme']);
6+
7+
task('polyfill.modern', (done) => {
8+
return src([
9+
'node_modules/zone.js/dist/zone.min.js',
10+
'node_modules/zone.js/dist/proxy.min.js',
11+
'node_modules/core-js/es6/array.js',
12+
'node_modules/core-js/es6/date.js',
13+
'node_modules/core-js/es6/function.js',
14+
'node_modules/core-js/es6/map.js',
15+
'node_modules/core-js/es6/number.js',
16+
'node_modules/core-js/es6/object.js',
17+
'node_modules/core-js/es6/parse-float.js',
18+
'node_modules/core-js/es6/parse-int.js',
19+
'node_modules/core-js/es6/promise.js',
20+
'node_modules/core-js/es6/set.js',
21+
'node_modules/core-js/es6/string.js',
22+
'node_modules/core-js/es7/reflect.js'
23+
])
24+
.pipe(concat('polyfills.modern.js'))
25+
.pipe(uglify())
26+
.pipe(dest('dist/ionic-angular/polyfills/'), done);
27+
});
28+
29+
task('polyfill.all', (done) => {
30+
return src([
31+
'node_modules/zone.js/dist/zone.min.js',
32+
'node_modules/zone.js/dist/proxy.min.js',
33+
'node_modules/core-js/es6/index.js',
34+
'node_modules/core-js/es7/reflect.js'
35+
])
36+
.pipe(concat('polyfills.js'))
37+
.pipe(uglify())
38+
.pipe(dest('dist/ionic-angular/polyfills/'), done);
39+
});
40+
41+
task('polyfill.ng', (done) => {
42+
return src([
43+
'node_modules/zone.js/dist/zone.min.js',
44+
'node_modules/zone.js/dist/proxy.min.js',
45+
'node_modules/core-js/es7/reflect.js'
46+
])
47+
.pipe(concat('polyfills.ng.js'))
48+
.pipe(uglify())
49+
.pipe(dest('dist/ionic-angular/polyfills/'), done);
50+
});
51+
52+
task('polyfill.copy-readme', (done) => {
53+
return src('scripts/npm/polyfills.readme.md')
54+
.pipe(dest('dist/ionic-angular/polyfills/README.md'), done);
55+
});

scripts/npm/polyfills.readme.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
## polyfills.js
2+
Contains all polyfills needed to work on the largest range of devices. This is the default polyfill.
3+
4+
##### Targets:
5+
- Android 4.4.2 and above
6+
- iOS back to iOS 8
7+
8+
##### Includes:
9+
- All ES6 features
10+
- zone.js
11+
- ES7 reflection
12+
13+
14+
## polyfills.modern.js
15+
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.
16+
17+
##### Targets:
18+
- Android 5.0 and above
19+
- iOS 9 and above
20+
21+
##### Includes:
22+
- zone.js
23+
- ES7 reflection,
24+
- ES6 polyfills, except for:
25+
new regexp features,
26+
math features,
27+
symbols,
28+
typed arrays,
29+
weak maps / weak sets
30+
31+
32+
## polyfills.ng.js
33+
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.
34+
35+
##### Targets:
36+
- Android 5.0 and above
37+
- iOS 10 and above
38+
39+
##### Includes:
40+
- zone.js
41+
- ES7 reflection
42+
43+
44+
## ECMAScript 6 Compatibility
45+
46+
To easily judge which polyfill you may need you can check this [ES6 support table](https://kangax.github.io/compat-table/es6/).

0 commit comments

Comments
 (0)