diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2020-05-04 21:35:21 +1000 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2020-05-04 21:35:21 +1000 |
commit | c8cb22863bf8c3ac157f6098be9154908aea9ec2 (patch) | |
tree | b27b1bf6ec4c90bbd0cb335e26bb9ece504285d2 /.config | |
parent | 59f09a1a2317e57d13bbe8f60e1949cc82199ead (diff) | |
download | svg.js-c8cb22863bf8c3ac157f6098be9154908aea9ec2.tar.gz svg.js-c8cb22863bf8c3ac157f6098be9154908aea9ec2.zip |
Fixed IE Polyfills, got rid of ArrayPolyfill in favour of babels own transforms, updated dependencies, finished tests, removed old es5 tests
Diffstat (limited to '.config')
-rw-r--r-- | .config/karma.conf.js | 58 | ||||
-rw-r--r-- | .config/karma.es6.js | 66 | ||||
-rw-r--r-- | .config/polyfillList.js | 8 | ||||
-rw-r--r-- | .config/rollup.config.js | 67 | ||||
-rw-r--r-- | .config/rollup.polyfills.js | 13 | ||||
-rw-r--r-- | .config/rollup.tests.js | 55 |
6 files changed, 127 insertions, 140 deletions
diff --git a/.config/karma.conf.js b/.config/karma.conf.js index 660c1d2..67667c7 100644 --- a/.config/karma.conf.js +++ b/.config/karma.conf.js @@ -1,5 +1,4 @@ // Karma configuration - const karmaCommon = require('./karma.conf.common.js') let chromeBin = 'ChromeHeadless' @@ -20,30 +19,52 @@ if (process.platform === 'linux') { module.exports = function (config) { config.set( Object.assign(karmaCommon(config), { + files: [ + 'spec/RAFPlugin.js', + { + pattern: 'spec/fixtures/fixture.css', + included: false, + served: true + }, + { + pattern: 'spec/fixtures/pixel.png', + included: false, + served: true + }, + { + pattern: 'src/**/*.js', + included: false, + served: true, + type: 'modules' + }, + { + pattern: 'spec/helpers.js', + included: false, + served: true, + type: 'module' + }, + { + pattern: 'spec/setupBrowser.js', + included: true, + type: 'module' + }, + { + pattern: 'spec/spec/*/**/*.js', + included: true, + type: 'module' + } + ], + // preprocess matching files before serving them to the browser // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor preprocessors: { - 'dist/svg.js': ['coverage'] + 'src/**/*.js': ['coverage'] }, - // this specifies which plugins karma should load - // by default all karma plugins, starting with `karma-` will load - // so if you are really puzzled why something isn't working, then comment - // out plugins: [] - it's here to make karma load faster - // get possible karma plugins by `ls node_modules | grep 'karma-*'` - plugins: [ - 'karma-chrome-launcher', - 'karma-coverage', - 'karma-firefox-launcher', - 'karma-jasmine' - ], - // test results reporter to use // possible values: 'dots', 'progress' // available reporters: https://npmjs.org/browse/keyword/karma-reporter reporters: ['progress', 'coverage'], - - // configure the coverage reporter coverageReporter: { // Specify a reporter type. type: 'lcov', @@ -51,6 +72,11 @@ module.exports = function (config) { subdir: function (browser) { // normalization process to keep a consistent browser name accross different OS return browser.toLowerCase().split(/[ /-]/)[0] // output the results into: './coverage/firefox/' + }, + instrumenterOptions: { + istanbul: { + esModules: true + } } }, diff --git a/.config/karma.es6.js b/.config/karma.es6.js deleted file mode 100644 index 8802c2d..0000000 --- a/.config/karma.es6.js +++ /dev/null @@ -1,66 +0,0 @@ -const karmaCommon = require('./karma.conf.common.js') - -module.exports = function (config) { - config.set( - Object.assign(karmaCommon(config), { - files: [ - 'spec/RAFPlugin.js', - { - pattern: 'spec/fixtures/fixture.css', - included: false, - served: true - }, - { - pattern: 'spec/fixtures/pixel.png', - included: false, - served: true - }, - { - pattern: 'src/**/*.js', - included: false, - served: true, - type: 'modules' - }, - { - pattern: 'spec/helpers.js', - included: false, - served: true, - type: 'module' - }, - { - pattern: 'spec/setupBrowser.js', - included: true, - type: 'module' - }, - { - pattern: 'spec/spec/*/**/*.js', - included: true, - type: 'module' - } - ], - - preprocessors: { - 'src/**/*.js': ['coverage'] - }, - - reporters: ['progress', 'coverage'], - coverageReporter: { - // Specify a reporter type. - type: 'lcov', - dir: 'coverage/', - subdir: function (browser) { - // normalization process to keep a consistent browser name accross different OS - return browser.toLowerCase().split(/[ /-]/)[0] // output the results into: './coverage/firefox/' - }, - instrumenterOptions: { - istanbul: { - esModules: true - } - } - }, - browsers: ['ChromeHeadless', 'FirefoxHeadless'], - singleRun: false, - concurrency: Infinity - }) - ) -} diff --git a/.config/polyfillList.js b/.config/polyfillList.js deleted file mode 100644 index c856f61..0000000 --- a/.config/polyfillList.js +++ /dev/null @@ -1,8 +0,0 @@ -import 'core-js/modules/es.object.assign' -import 'core-js/modules/es.object.keys' -import 'core-js/modules/es.function.name' -import 'core-js/modules/es.symbol' -import 'core-js/modules/es.set' -import 'core-js/modules/es.array.includes' -import 'core-js/modules/es.string.includes' -import 'core-js/modules/es.array.from' diff --git a/.config/rollup.config.js b/.config/rollup.config.js index 433bcd9..bcbab0c 100644 --- a/.config/rollup.config.js +++ b/.config/rollup.config.js @@ -1,10 +1,9 @@ -import babel from 'rollup-plugin-babel' import * as pkg from '../package.json' +import babel from '@rollup/plugin-babel' +import resolve from '@rollup/plugin-node-resolve' +import commonjs from '@rollup/plugin-commonjs' import filesize from 'rollup-plugin-filesize' -// import { terser } from 'rollup-plugin-terser' -import resolve from 'rollup-plugin-node-resolve' -import commonjs from 'rollup-plugin-commonjs' -import { uglify } from 'rollup-plugin-uglify' +import { terser } from 'rollup-plugin-terser' const buildDate = Date() @@ -21,22 +20,41 @@ const headerLong = `/*! const headerShort = `/*! ${pkg.name} v${pkg.version} ${pkg.license}*/;` -const getBabelConfig = (targets, corejs = false) => babel({ - include: 'src/**', - runtimeHelpers: true, - babelrc: false, - presets: [['@babel/preset-env', { - modules: false, - targets: targets || pkg.browserslist, - useBuiltIns: 'usage', - corejs: 3 - }]], - plugins: [['@babel/plugin-transform-runtime', { - corejs: corejs, - helpers: true, - useESModules: true - }]] -}) +const getBabelConfig = (node = false) => { + + let targets = pkg.browserslist + const plugins = [ + ['@babel/plugin-transform-classes'], + ['@babel/plugin-transform-runtime', { + corejs: 3, + helpers: true, + useESModules: true, + version: "^7.9.6", + regenerator: false + }] + ] + + if (node) { + plugins.shift() + targets = 'maintained node versions' + } + + return babel({ + include: 'src/**', + babelHelpers: 'runtime', + babelrc: false, + presets: [['@babel/preset-env', { + modules: false, + targets: targets || pkg.browserslist, + // useBuildins and plugin-transform-runtime are mutually exclusive + // https://github.com/babel/babel/issues/10271#issuecomment-528379505 + // use babel-polyfills when released + useBuiltIns: false, + bugfixes: true + }]], + plugins + }) +} // When few of these get mangled nothing works anymore // We loose literally nothing by let these unmangled @@ -94,7 +112,7 @@ const config = (node, min, esm = false) => ({ commonjs(), getBabelConfig(node && 'maintained node versions'), filesize(), - !min ? {} : uglify({ + !min ? {} : terser({ mangle: { reserved: classes }, @@ -102,10 +120,11 @@ const config = (node, min, esm = false) => ({ preamble: headerShort } }) - ] + ], + //external: ['@babel/runtime', '@babel/runtime-corejs3'] }) -// [node, minified] +// [node, minified, esm] const modes = [[false], [false, true], [true], [false, false, true]] export default modes.map(m => config(...m)) diff --git a/.config/rollup.polyfills.js b/.config/rollup.polyfills.js index 1df059a..f089ceb 100644 --- a/.config/rollup.polyfills.js +++ b/.config/rollup.polyfills.js @@ -1,22 +1,21 @@ -import resolve from 'rollup-plugin-node-resolve' -import commonjs from 'rollup-plugin-commonjs' +import resolve from '@rollup/plugin-node-resolve' +import commonjs from '@rollup/plugin-commonjs' import { terser } from 'rollup-plugin-terser' import filesize from 'rollup-plugin-filesize' // We dont need babel. All polyfills are compatible const config = (ie) => ({ - input: ie ? './.config/polyfillListIE.js' : './.config/polyfillList.js', + input: './.config/polyfillListIE.js', output: { - file: ie ? 'dist/polyfillsIE.js' : 'dist/polyfills.js', - sourceMap: false, + file: 'dist/polyfillsIE.js', format: 'iife' }, plugins: [ resolve({ browser: true }), commonjs(), - terser(), + //terser(), filesize() ] }) -export default [false, true].map(config) +export default [true].map(config) diff --git a/.config/rollup.tests.js b/.config/rollup.tests.js index e524a79..3620149 100644 --- a/.config/rollup.tests.js +++ b/.config/rollup.tests.js @@ -1,5 +1,33 @@ -import babel from 'rollup-plugin-babel' -import multiEntry from 'rollup-plugin-multi-entry' +import * as pkg from '../package.json' +import babel from '@rollup/plugin-babel' +import multiEntry from '@rollup/plugin-multi-entry' +import resolve from '@rollup/plugin-node-resolve' +import commonjs from '@rollup/plugin-commonjs' + +const getBabelConfig = (targets) => babel({ + include: ['src/**', 'spec/**/*'], + babelHelpers: 'runtime', + babelrc: false, + presets: [['@babel/preset-env', { + modules: false, + targets: targets || pkg.browserslist, + // useBuildins and plugin-transform-runtime are mutually exclusive + // https://github.com/babel/babel/issues/10271#issuecomment-528379505 + // use babel-polyfills when released + useBuiltIns: false, + // corejs: 3, + bugfixes: true + }]], + plugins: [ + ['@babel/plugin-transform-runtime', { + corejs: 3, + helpers: true, + useESModules: true, + version: "^7.9.6", + regenerator: false + }] + ] +}) export default { input: [ @@ -9,24 +37,13 @@ export default { output: { file: 'spec/es5TestBundle.js', name: 'SVGTests', - sourceMap: true, - format: 'iife' + format: 'iife', }, plugins: [ - babel({ - include: 'src/**', - runtimeHelpers: true, - babelrc: false, - presets: [['@babel/preset-env', { - modules: false - }]] - // plugins: [["@babel/plugin-transform-runtime", { - // corejs: false, - // helpers: true, - // regenerator: true, - // useESModules: true - // }]] - }), + resolve({ browser: true }), + commonjs(), + getBabelConfig(), multiEntry() - ] + ], + external: ['@babel/runtime', '@babel/runtime-corejs3'] } |