summaryrefslogtreecommitdiffstats
path: root/.config
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-12-01 13:32:23 +0100
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-12-01 13:32:23 +0100
commit637039fbde6a68f18f89ce8677f6b8ca667ba689 (patch)
tree25538f2650623b9636958119d0a169c9780f5ae2 /.config
parent998b422fa24c4f45b0265779cdf4d0833788040a (diff)
downloadsvg.js-637039fbde6a68f18f89ce8677f6b8ca667ba689.tar.gz
svg.js-637039fbde6a68f18f89ce8677f6b8ca667ba689.zip
dont generate esm bundle anymore and link to src/main.js directly. Move bower to its own repo
rename makeNode back to create
Diffstat (limited to '.config')
-rw-r--r--.config/rollup.config.js52
-rw-r--r--.config/rollup.tests.js29
2 files changed, 51 insertions, 30 deletions
diff --git a/.config/rollup.config.js b/.config/rollup.config.js
index 32096e5..c056776 100644
--- a/.config/rollup.config.js
+++ b/.config/rollup.config.js
@@ -21,13 +21,13 @@ const headerLong = `/*!
const headerShort = `/*! ${pkg.name} v${pkg.version} ${pkg.license}*/;`
-const getBabelConfig = (esm, targets = { esmodules: true }, corejs = false) => babel({
+const getBabelConfig = (targets, corejs = false) => babel({
include: 'src/**',
runtimeHelpers: true,
babelrc: false,
presets: [['@babel/preset-env', {
modules: false,
- targets: esm ? targets : pkg.browserslist,
+ targets: targets || pkg.browserslist,
useBuiltIns: 'usage'
}]],
plugins: [['@babel/plugin-transform-runtime', {
@@ -70,21 +70,29 @@ const classes = [
'Use'
]
-const config = esm => ({
- input: esm ? './src/main.js' : './src/svg.js',
+const config = (node, min) => ({
+ input: node ? './src/main.js' : './src/svg.js',
output: {
- file: esm ? './dist/svg.js' : './dist/svg.min.js',
+ file: node ? './dist/svg.node.js'
+ : min ? './dist/svg.min.js'
+ : './dist/svg.js',
+ format: node ? 'cjs' : 'iife',
name: 'SVG',
- sourcemap: 'external',
- format: esm ? 'esm' : 'iife',
- banner: esm ? headerLong : headerShort
+ sourcemap: true,
+ banner: headerLong,
+ // remove Object.freeze
+ freeze: false
+ },
+ treeshake: {
+ // property getter have no sideeffects
+ propertyReadSideEffects: false
},
plugins: [
- resolve({ browser: true }),
+ resolve({ browser: !node }),
commonjs(),
- getBabelConfig(esm),
+ getBabelConfig(node && 'maintained node versions'),
filesize(),
- esm ? {} : uglify({
+ !min ? {} : uglify({
mangle: {
reserved: classes
},
@@ -95,23 +103,7 @@ const config = esm => ({
]
})
-const nodeConfig = () => ({
- input: './src/main.js',
- output: {
- file: './dist/svg.node.js',
- name: 'SVG',
- sourcemap: 'external',
- format: 'cjs',
- banner: headerLong
- },
- plugins: [
- resolve(),
- commonjs(),
- getBabelConfig(true, 'maintained node versions'),
- filesize()
- ]
-})
-
-const modes = [true, false]
+// [node, minified]
+const modes = [[false], [false, true], [true]]
-export default modes.map(config).concat(nodeConfig())
+export default modes.map(m => config(...m))
diff --git a/.config/rollup.tests.js b/.config/rollup.tests.js
new file mode 100644
index 0000000..518be94
--- /dev/null
+++ b/.config/rollup.tests.js
@@ -0,0 +1,29 @@
+import babel from 'rollup-plugin-babel'
+import multiEntry from 'rollup-plugin-multi-entry'
+
+export default {
+ input: ['spec/setupBrowser.js', 'spec/spec/types/*.js', 'spec/spec/utils/*.js'],
+ output: {
+ file: 'spec/es5TestBundle.js',
+ name: 'SVGTests',
+ sourceMap: true,
+ 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
+ // }]]
+ }),
+ multiEntry()
+ ]
+}