From a252388e7f9b9378c1c055263a1cdb22d801a4ca Mon Sep 17 00:00:00 2001 From: Justin Willis Date: Thu, 15 Sep 2016 23:38:35 -0500 Subject: [PATCH] chore(build): generate static polyfills --- package.json | 6 +- scripts/gulp/gulpfile.ts | 2 +- scripts/gulp/tasks/polyfill.ts | 100 ++++++++++++++++++++++++++++++++ scripts/gulp/tasks/polyfills.ts | 55 ------------------ 4 files changed, 106 insertions(+), 57 deletions(-) create mode 100644 scripts/gulp/tasks/polyfill.ts delete mode 100644 scripts/gulp/tasks/polyfills.ts diff --git a/package.json b/package.json index 2ec0cc2777..215ca0d93e 100644 --- a/package.json +++ b/package.json @@ -75,7 +75,6 @@ "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", @@ -96,6 +95,11 @@ "remap-istanbul": "^0.6.4", "request": "2.53.0", "resolve-bin": "^0.4.0", + "rollup": "^0.35.10", + "rollup-plugin-commonjs": "^4.1.0", + "rollup-plugin-multi-entry": "^2.0.1", + "rollup-plugin-node-resolve": "^2.0.0", + "rollup-plugin-uglify": "^1.0.1", "run-sequence": "^1.1.0", "sassdoc": "^2.1.20", "semver": "^5.0.1", diff --git a/scripts/gulp/gulpfile.ts b/scripts/gulp/gulpfile.ts index 3aa366f14d..77ab66e7d5 100644 --- a/scripts/gulp/gulpfile.ts +++ b/scripts/gulp/gulpfile.ts @@ -6,5 +6,5 @@ import './tasks/lint'; import './tasks/release'; import './tasks/snapshot'; import './tasks/test'; -import './tasks/polyfills'; +import './tasks/polyfill'; //import './tasks/theme'; diff --git a/scripts/gulp/tasks/polyfill.ts b/scripts/gulp/tasks/polyfill.ts new file mode 100644 index 0000000000..f37d2b013d --- /dev/null +++ b/scripts/gulp/tasks/polyfill.ts @@ -0,0 +1,100 @@ +import { task, src, dest } from 'gulp'; +const rollup = require('rollup'); +const nodeResolve = require('rollup-plugin-node-resolve'); +const commonjs = require('rollup-plugin-commonjs'); +const multiEntry = require('rollup-plugin-multi-entry'); +const uglify = require('rollup-plugin-uglify'); + +const nodeResolveOptions = { + jsnext: true, + main: true +}; + +const modernEntries = [ + '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', + 'node_modules/core-js/es6/reflect.js', + 'node_modules/zone.js/dist/zone.js', +]; + +const allEntries = [ + 'node_modules/core-js/es6/index.js', + 'node_modules/core-js/es7/reflect.js', + 'node_modules/zone.js/dist/zone.js', +]; + +const ngEntries = [ + 'node_modules/core-js/es7/reflect.js', + 'node_modules/zone.js/dist/zone.js', +]; + +task('polyfill', ['polyfill.modern', 'polyfill.all', 'polyfill.ng', 'polyfill.copy-readme']); + +task('polyfill.all', () => { + return rollup.rollup({ + entry: allEntries, + plugins: [ + multiEntry(), + nodeResolve(nodeResolveOptions), + commonjs(), + uglify() + ] + }).then((bundle) => { + bundle.write({ + format: 'iife', + moduleName: 'MyBundle', + dest: 'dist/ionic-angular/polyfills/polyfills.js' + }); + }); +}); + +task('polyfill.ng', () => { + return rollup.rollup({ + entry: ngEntries, + plugins: [ + multiEntry(), + nodeResolve(nodeResolveOptions), + commonjs(), + uglify() + ] + }).then((bundle) => { + bundle.write({ + format: 'iife', + moduleName: 'MyBundle', + dest: 'dist/ionic-angular/polyfills/polyfills.ng.js' + }); + }); +}); + +task('polyfill.modern', (done) => { + return rollup.rollup({ + entry: modernEntries, + plugins: [ + multiEntry(), + nodeResolve(nodeResolveOptions), + commonjs(), + uglify() + ] + }).then((bundle) => { + bundle.write({ + format: 'iife', + moduleName: 'MyBundle', + dest: 'dist/ionic-angular/polyfills/polyfills.modern.js' + }); + }); +}); + +task('polyfill.copy-readme', (done) => { + return src('scripts/npm/polyfills.readme.md') + .pipe(dest('dist/ionic-angular/polyfills/'), done); +}); diff --git a/scripts/gulp/tasks/polyfills.ts b/scripts/gulp/tasks/polyfills.ts deleted file mode 100644 index d1bf460e74..0000000000 --- a/scripts/gulp/tasks/polyfills.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { task, src, dest } from 'gulp'; -const concat = require('gulp-concat'); -const uglify = require('gulp-uglify'); - -task('polyfills', ['polyfills.modern', 'polyfills.all', 'polyfills.ng', 'polyfills.copy-readme']); - -task('polyfills.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('polyfills.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('polyfills.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('polyfills.copy-readme', (done) => { - return src('scripts/npm/polyfills.readme.md') - .pipe(dest('dist/ionic-angular/polyfills/README.md'), done); -});