Skip to content

Commit 0b914ae

Browse files
committed
chore(demos): generating polyfills at build time
generating polyfills at build time
1 parent ace4c1c commit 0b914ae

13 files changed

Lines changed: 119 additions & 123 deletions

File tree

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ scripts/build/e2e-generated-tsconfig.json
3131

3232
# demo stuff
3333
demos/node_modules
34+
demos/polyfills
3435
demos/css
3536
demos/fonts
3637
demos/src/**/*.js*

‎demos/polyfills/README.md‎

Lines changed: 0 additions & 56 deletions
This file was deleted.

‎demos/polyfills/polyfills.js‎

Lines changed: 0 additions & 3 deletions
This file was deleted.

‎demos/polyfills/polyfills.modern.js‎

Lines changed: 0 additions & 3 deletions
This file was deleted.

‎demos/polyfills/polyfills.ng.js‎

Lines changed: 0 additions & 2 deletions
This file was deleted.

‎scripts/gulp/declarations.d.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ declare module 'gulp-tslint';
66
declare module 'html-entities';
77
declare module 'rollup';
88
declare module 'rollup-plugin-commonjs';
9+
declare module 'rollup-plugin-multi-entry';
910
declare module 'rollup-plugin-node-resolve';
11+
declare module 'rollup-plugin-uglify';
1012
declare module 'vinyl';
1113
declare module 'yargs';

‎scripts/gulp/tasks/demos.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import * as nodeResolve from 'rollup-plugin-node-resolve';
88
import * as commonjs from 'rollup-plugin-commonjs';
99

1010
import { DEMOS_ROOT, DEMOS_SRC_ROOT} from '../constants';
11-
import { compileSass, copyFonts, createTimestamp, deleteFiles, runNgc, setSassIonicVersion } from '../util';
11+
import { compileSass, copyFonts, createTimestamp, deleteFiles, runNgc, setSassIonicVersion, writePolyfills } from '../util';
1212

1313
function doNpmInstall() {
1414
return new Promise((resolve, reject) => {
@@ -32,6 +32,10 @@ function doNpmInstall() {
3232
});
3333
}
3434

35+
function generatePolyfills() {
36+
return writePolyfills(join(DEMOS_ROOT, 'polyfills'));
37+
}
38+
3539
function compileTests() {
3640
console.log('Starting to compile tests defined via tsconfig ...');
3741
return new Promise((resolve, reject) => {
@@ -111,6 +115,8 @@ function buildDemos(done: Function) {
111115
return compileTests();
112116
}).then(() => {
113117
return rollupTests();
118+
}).then(() => {
119+
return generatePolyfills();
114120
}).then(() => {
115121
done();
116122
}).catch(err => {
@@ -126,6 +132,7 @@ function cleanDemos(done: Function) {
126132
`${DEMOS_SRC_ROOT}/**/*.metadata.json`,
127133
`${DEMOS_ROOT}/css`,
128134
`${DEMOS_ROOT}/fonts`,
135+
`${DEMOS_ROOT}/polyfills`,
129136
], done);
130137
}
131138

‎scripts/gulp/tasks/docs.ts‎

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,57 @@ task('docs', () => {
2929
}
3030
});
3131

32-
task('docs.copyDemos', ['demos.build'], () => {
32+
task('docs.copyDemos', [], (done: Function) => {
3333
const config = require('../../config.json');
3434
const outputDir = join(config.docsDest, 'dist', 'demos');
35-
return src([`${DEMOS_ROOT}/css`, `${DEMOS_ROOT}/fonts`, `${DEMOS_ROOT}/polyfills`, `${DEMOS_SRC_ROOT}`])
36-
.pipe(dest(outputDir));
35+
let promises = [];
36+
promises.push(copyDemoCss(join(outputDir, 'css')));
37+
promises.push(copyDemoFonts(join(outputDir, 'fonts')));
38+
promises.push(copyDemoPolyfills(join(outputDir, 'polyfills')));
39+
promises.push(copyDemoContent(join(outputDir, 'src')));
40+
Promise.all(promises).then(() => {
41+
done();
42+
}).catch(err => {
43+
done(err);
44+
});
3745
});
3846

47+
function copyDemoCss(outputDir: string) {
48+
return new Promise((resolve, reject) => {
49+
const stream = src(`${DEMOS_ROOT}/css/*`).pipe(dest(outputDir));
50+
stream.on('end', () => {
51+
resolve();
52+
});
53+
});
54+
}
55+
56+
function copyDemoFonts(outputDir: string) {
57+
return new Promise((resolve, reject) => {
58+
const stream = src(`${DEMOS_ROOT}/fonts/*`).pipe(dest(outputDir));
59+
stream.on('end', () => {
60+
resolve();
61+
});
62+
});
63+
}
64+
65+
function copyDemoPolyfills(outputDir: string) {
66+
return new Promise((resolve, reject) => {
67+
const stream = src(`${DEMOS_ROOT}/polyfills/*`).pipe(dest(outputDir));
68+
stream.on('end', () => {
69+
resolve();
70+
});
71+
});
72+
}
73+
74+
function copyDemoContent(outputDir: string) {
75+
return new Promise((resolve, reject) => {
76+
const stream = src([`${DEMOS_ROOT}/src/**/main.html`, `${DEMOS_ROOT}/src/**/main.bundle.js`, `${DEMOS_ROOT}/src/scrollbar-fix.*`]).pipe(dest(outputDir));
77+
stream.on('end', () => {
78+
resolve();
79+
});
80+
});
81+
}
82+
3983
task('docs.sassVariables', () => {
4084
let variables = [];
4185
const outputFile = 'tmp/sass.json';

‎scripts/gulp/tasks/e2e.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@ function e2eBuild(done: (err: any) => void) {
2323
runSequence('e2e.polyfill', 'e2e.copySource', 'e2e.compileTests', 'e2e.copyExternalDependencies', 'e2e.sass', 'e2e.fonts', 'e2e.bundle', done);
2424
}
2525

26-
task('e2e.polyfill', () => {
27-
writePolyfills('dist/e2e/polyfills');
26+
task('e2e.polyfill', (done: Function) => {
27+
writePolyfills('dist/e2e/polyfills').then(() => {
28+
done();
29+
}).catch(err => {
30+
done(err);
31+
});
2832
});
2933

3034
task('e2e.copyAndCompile', (done: (err: any) => void) => {
@@ -312,4 +316,3 @@ function e2eComponentsExists(): boolean {
312316
}
313317
return true;
314318
}
315-

‎scripts/gulp/tasks/polyfill.source.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import { task } from 'gulp';
22
import { writePolyfills } from '../util';
33

44

5-
task('src.polyfill', () => {
6-
writePolyfills('scripts/polyfill');
5+
task('src.polyfill', (done: Function) => {
6+
writePolyfills('scripts/polyfill').then(() => {
7+
done();
8+
}).catch(err => {
9+
done(err);
10+
});
711
});

0 commit comments

Comments
 (0)