mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 04:14:21 +08:00
feat(polyfills): split up code and source polyfill task (#8130)
* feat(polyfills): split up code and source polyfill task * fix(polyfills): get rid of need for entries argument
This commit is contained in:
committed by
Dan Bucholtz
parent
11f4f516fc
commit
bcec66c67b
@ -2,6 +2,11 @@ import { COMMONJS_MODULE, ES_MODULE, NODE_MODULES_ROOT, PROJECT_ROOT, SRC_ROOT,
|
||||
import { src, dest } from 'gulp';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
import { rollup } from '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');
|
||||
|
||||
export function mergeObjects(obj1: any, obj2: any ) {
|
||||
if (! obj1) {
|
||||
@ -173,3 +178,71 @@ export function createTimestamp() {
|
||||
('0' + (d.getUTCHours())).slice(-2) + // HH
|
||||
('0' + (d.getUTCMinutes())).slice(-2); // MM
|
||||
}
|
||||
|
||||
export function writePolyfills(pathToWrite: string) {
|
||||
const MODERN_ENTRIES = [
|
||||
'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 ALL_ENTRIES = [
|
||||
'node_modules/core-js/es6/index.js',
|
||||
'node_modules/core-js/es7/reflect.js',
|
||||
'node_modules/zone.js/dist/zone.js',
|
||||
];
|
||||
|
||||
const NG_ENTRIES = [
|
||||
'node_modules/core-js/es7/reflect.js',
|
||||
'node_modules/zone.js/dist/zone.js',
|
||||
];
|
||||
|
||||
const ENTRIES = [
|
||||
{
|
||||
entry: MODERN_ENTRIES,
|
||||
fileName: 'polyfills.modern.js'
|
||||
}, {
|
||||
entry: ALL_ENTRIES,
|
||||
fileName: 'polyfills.js'
|
||||
}, {
|
||||
entry: NG_ENTRIES,
|
||||
fileName: 'polyfills.ng.js'
|
||||
}
|
||||
];
|
||||
|
||||
for (let i = 0; i <= 3; i++) {
|
||||
if (i === 3) {
|
||||
return;
|
||||
} else {
|
||||
rollup({
|
||||
entry: ENTRIES[i].entry,
|
||||
plugins: [
|
||||
multiEntry(),
|
||||
nodeResolve({
|
||||
jsnext: true,
|
||||
main: true
|
||||
}),
|
||||
commonjs(),
|
||||
uglify()
|
||||
]
|
||||
}).then((bundle) => {
|
||||
bundle.write({
|
||||
format: 'iife',
|
||||
moduleName: 'MyBundle',
|
||||
dest: `${pathToWrite}/${ENTRIES[i].fileName}`
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user