Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix pan #47

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 58 additions & 36 deletions .config/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,66 +21,88 @@ 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'
}]],
plugins: [['@babel/plugin-transform-runtime', {
corejs: corejs,
helpers: true,
useESModules: true
}]]
})
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-proposal-optional-chaining'],
[
'@babel/plugin-proposal-nullish-coalescing-operator',
{
loose: true
}
],
[
'@babel/plugin-transform-runtime',
{
corejs: corejs,
helpers: true,
useESModules: true
}
]
]
})

// When few of these get mangled nothing works anymore
// We loose literally nothing by let these unmangled
const classes = [

]
const classes = []

const config = (node, min) => ({
const config = (node, min, esm = false) => ({
external: ['@svgdotjs/svg.js'],
input: 'src/svg.panzoom.js',
output: {
file: node ? './dist/svg.panzoom.node.js'
: min ? './dist/svg.panzoom.min.js'
: './dist/svg.panzoom.js',
format: node ? 'cjs' : 'iife',
//name: 'SVG.Filter',
file: esm
? './dist/svg.panzoom.esm.js'
: node
? './dist/svg.panzoom.node.js'
: min
? './dist/svg.panzoom.min.js'
: './dist/svg.panzoom.js',
format: esm ? 'esm' : node ? 'cjs' : 'iife',
sourcemap: true,
banner: headerLong,
// remove Object.freeze
freeze: false,
globals: {
'@svgdotjs/svg.js': 'SVG',
},
'@svgdotjs/svg.js': 'SVG'
}
},
treeshake: {
// property getter have no sideeffects
propertyReadSideEffects: false
},
plugins: [
resolve(),
commonjs(),
getBabelConfig(node && 'maintained node versions'),
commonjs(),
filesize(),
!min ? {} : uglify({
mangle: {
reserved: classes
},
output: {
preamble: headerShort
}
})
!min
? {}
: uglify({
mangle: {
reserved: classes
},
output: {
preamble: headerShort
}
})
]
})

// [node, minified]
const modes = [[false], [false, true]]
const modes = [[false], [false, true], [false, false, true]]

export default modes.map(m => config(...m))
11 changes: 4 additions & 7 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@

extends: standard
extends: [standard]
parser: babel-eslint
rules:
operator-linebreak: [ error, before ]
object-curly-spacing: [ error, always ]
indent: [ error, 2, {
flatTernaryExpressions: true
}]
object-curly-spacing: [error, always]
indent: [error, 2, { flatTernaryExpressions: true }]
padded-blocks: off
Loading