diff options
author | Hakim El Hattab <hakim.elhattab@gmail.com> | 2020-05-26 09:46:50 +0200 |
---|---|---|
committer | Hakim El Hattab <hakim.elhattab@gmail.com> | 2020-05-26 09:47:01 +0200 |
commit | e6244a57b549ad788d02596c98ff33f6c348899e (patch) | |
tree | 6717fff3b4d6ad5f286d707b3cc64e59d7836419 /gulpfile.js | |
parent | b074050a6d4dd7beaf115805859af40f7a25e6db (diff) | |
download | fosdem-2021-minimalism-presentation-e6244a57b549ad788d02596c98ff33f6c348899e.tar fosdem-2021-minimalism-presentation-e6244a57b549ad788d02596c98ff33f6c348899e.tar.gz |
fix polyfills, add ie11 support
Diffstat (limited to 'gulpfile.js')
-rw-r--r-- | gulpfile.js | 69 |
1 files changed, 40 insertions, 29 deletions
diff --git a/gulpfile.js b/gulpfile.js index 23e2f01..d3ee0ef 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -7,9 +7,9 @@ const qunit = require('node-qunit-puppeteer') const {rollup} = require('rollup') const {terser} = require('rollup-plugin-terser') -const babel = require('rollup-plugin-babel') +const babel = require('@rollup/plugin-babel').default const commonjs = require('@rollup/plugin-commonjs') -const resolve = require('@rollup/plugin-node-resolve') +const resolve = require('@rollup/plugin-node-resolve').default const gulp = require('gulp') const tap = require('gulp-tap') @@ -36,42 +36,35 @@ const banner = `/*! process.setMaxListeners(20); const babelConfig = { - exclude: 'node_modules/**', + babelHelpers: 'bundled', + ignore: ['node_modules'], compact: false, extensions: ['.js', '.html'], - plugins: ['transform-html-import-to-string'], + plugins: [ + 'transform-html-import-to-string' + ], presets: [[ '@babel/preset-env', { corejs: 3, - useBuiltIns: 'entry', + useBuiltIns: 'usage', modules: false } ]] }; -const rollupConfig = { - plugins: [ - babel( babelConfig ), - resolve(), - commonjs(), - terser() - ] -}; - -// Our ES module bundle only needs to support modern -// browser features +// Our ES module bundle only targets newer browsers with +// module support. Browsers are targeted explicitly instead +// of using the "esmodule: true" target since that leads to +// polyfilling older browsers and a larger bundle. const babelConfigESM = JSON.parse( JSON.stringify( babelConfig ) ); -babelConfigESM.presets[0][1].targets = { esmodules: true }; - -const rollupConfigESM = { - plugins: [ - babel( babelConfigESM ), - resolve(), - commonjs(), - terser() - ] -}; +babelConfigESM.presets[0][1].targets = { browsers: [ + 'last 2 Chrome versions', 'not Chrome < 60', + 'last 2 Safari versions', 'not Safari < 10.1', + 'last 2 iOS versions', 'not iOS < 10.3', + 'last 2 Firefox versions', 'not Firefox < 60', + 'last 2 Edge versions', 'not Edge < 16', +] }; let rollupCache; @@ -81,7 +74,12 @@ gulp.task('js-es5', () => { return rollup({ cache: rollupCache, input: 'js/index.js', - ...rollupConfig + plugins: [ + resolve(), + commonjs(), + babel( babelConfig ), + terser() + ] }).then( bundle => { rollupCache = bundle.cache; return bundle.write({ @@ -99,7 +97,12 @@ gulp.task('js-es6', () => { return rollup({ cache: rollupCache, input: 'js/index.js', - ...rollupConfigESM + plugins: [ + resolve(), + commonjs(), + babel( babelConfigESM ), + terser() + ] }).then( bundle => { rollupCache = bundle.cache; return bundle.write({ @@ -125,7 +128,15 @@ gulp.task('plugins', () => { ].map( plugin => { return rollup({ input: plugin.input, - ...rollupConfig + plugins: [ + resolve(), + commonjs(), + babel({ + ...babelConfig, + ignore: [/node_modules\/(?!(highlight\.js|marked)\/).*/], + }), + terser() + ] }).then( bundle => { bundle.write({ file: plugin.output + '.esm.js', |