Skip to content

Commit

Permalink
rollup cache for all js bunling, improves subsequent build time by 50%
Browse files Browse the repository at this point in the history
  • Loading branch information
hakimel committed May 27, 2020
1 parent b1e5db0 commit fc62af9
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ babelConfigESM.presets[0][1].targets = { browsers: [
'last 2 Edge versions', 'not Edge < 16',
] };

let rollupCache;
let cache = {};

// Creates a bundle with broad browser support, exposed
// as UMD
gulp.task('js-es5', () => {
return rollup({
cache: rollupCache,
cache: cache.umd,
input: 'js/index.js',
plugins: [
resolve(),
Expand All @@ -81,7 +81,7 @@ gulp.task('js-es5', () => {
terser()
]
}).then( bundle => {
rollupCache = bundle.cache;
cache.umd = bundle.cache;
return bundle.write({
name: 'Reveal',
file: './dist/reveal.js',
Expand All @@ -95,7 +95,7 @@ gulp.task('js-es5', () => {
// Creates an ES module bundle
gulp.task('js-es6', () => {
return rollup({
cache: rollupCache,
cache: cache.esm,
input: 'js/index.js',
plugins: [
resolve(),
Expand All @@ -104,7 +104,7 @@ gulp.task('js-es6', () => {
terser()
]
}).then( bundle => {
rollupCache = bundle.cache;
cache.esm = bundle.cache;
return bundle.write({
file: './dist/reveal.esm.js',
format: 'es',
Expand All @@ -127,6 +127,7 @@ gulp.task('plugins', () => {
{ name: 'RevealMath', input: './plugin/math/plugin.js', output: './plugin/math/math' },
].map( plugin => {
return rollup({
cache: cache[plugin.input],
input: plugin.input,
plugins: [
resolve(),
Expand All @@ -138,6 +139,7 @@ gulp.task('plugins', () => {
terser()
]
}).then( bundle => {
cache[plugin.input] = bundle.cache;
bundle.write({
file: plugin.output + '.esm.js',
name: plugin.name,
Expand Down

0 comments on commit fc62af9

Please sign in to comment.