diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2023-06-13 01:43:37 +0200 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2023-06-13 01:43:37 +0200 |
commit | 03322672782a6318b019eff33fe44ec800d6f12c (patch) | |
tree | 9d807e1585cf28a1ea98e87b855932dba00f1880 /.config/rollup.config.js | |
parent | 8e18b4698edd00f83af0be05bb3374f92fecaeb9 (diff) | |
download | svg.js-03322672782a6318b019eff33fe44ec800d6f12c.tar.gz svg.js-03322672782a6318b019eff33fe44ec800d6f12c.zip |
dependency updates, easier formatting
Diffstat (limited to '.config/rollup.config.js')
-rw-r--r-- | .config/rollup.config.js | 81 |
1 files changed, 48 insertions, 33 deletions
diff --git a/.config/rollup.config.js b/.config/rollup.config.js index 8391ba0..586e8ea 100644 --- a/.config/rollup.config.js +++ b/.config/rollup.config.js @@ -1,9 +1,9 @@ -import * as pkg from '../package.json' +import pkg from '../package.json' assert { type: '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 terser from '@rollup/plugin-terser' const buildDate = Date() @@ -21,17 +21,22 @@ const headerLong = `/*! const headerShort = `/*! ${pkg.name} v${pkg.version} ${pkg.license}*/;` const getBabelConfig = (node = false) => { - let targets = pkg.browserslist const plugins = [ - ['@babel/transform-runtime', { - version: "^7.14.5", - regenerator: false, - useESModules: true - }], - ["polyfill-corejs3", { - "method": "usage-pure" - }] + [ + '@babel/transform-runtime', + { + version: '^7.14.5', + regenerator: false, + useESModules: true + } + ], + [ + 'polyfill-corejs3', + { + method: 'usage-pure' + } + ] ] if (node) { @@ -43,15 +48,20 @@ const getBabelConfig = (node = false) => { babelHelpers: 'runtime', babelrc: false, targets: targets, - presets: [['@babel/preset-env', { - modules: false, - // 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, - loose: true - }]], + presets: [ + [ + '@babel/preset-env', + { + modules: false, + // 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, + loose: true + } + ] + ], plugins }) } @@ -90,11 +100,14 @@ const classes = [ ] const config = (node, min, esm = false) => ({ - input: (node || esm) ? './src/main.js' : './src/svg.js', + input: node || esm ? './src/main.js' : './src/svg.js', output: { - file: esm ? './dist/svg.esm.js' - : node ? './dist/svg.node.js' - : min ? './dist/svg.min.js' + file: esm + ? './dist/svg.esm.js' + : node + ? './dist/svg.node.js' + : min + ? './dist/svg.min.js' : './dist/svg.js', format: esm ? 'esm' : node ? 'cjs' : 'iife', name: 'SVG', @@ -112,18 +125,20 @@ const config = (node, min, esm = false) => ({ commonjs(), getBabelConfig(node), filesize(), - !min ? {} : terser({ - mangle: { - reserved: classes - }, - output: { - preamble: headerShort - } - }) + !min + ? {} + : terser({ + mangle: { + reserved: classes + }, + output: { + preamble: headerShort + } + }) ] }) // [node, minified, esm] const modes = [[false], [false, true], [true], [false, false, true]] -export default modes.map(m => config(...m)) +export default modes.map((m) => config(...m)) |