Skip to content

Commit

Permalink
fix(rollup): only build cjs, esm, iife
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanGerbeth committed Oct 27, 2019
1 parent 57a1390 commit ecb947c
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 29 deletions.
56 changes: 27 additions & 29 deletions .rolluprc
Expand Up @@ -2,15 +2,7 @@ import babel from 'rollup-plugin-babel';
import resolve from 'rollup-plugin-node-resolve';
import minify from 'rollup-plugin-babel-minify';
import visualizer from 'rollup-plugin-visualizer';

const plugins = [
resolve(),
minify({
comments: false,
banner: '/* vector class - MIT License */',
bannerNewLine: true
})
];
import commonjs from 'rollup-plugin-commonjs';

export default [
{
Expand All @@ -19,26 +11,27 @@ export default [
'operator': 'src/operator.js',
'adapter/playcanvas': 'src/adapter/playcanvas.js'
},
output: [{
dir: './build/esm',
exports: 'named',
format: 'esm'
}, {
dir: './build/cjs',
exports: 'named',
format: 'cjs'
}, {
dir: './build/amd',
exports: 'named',
format: 'amd'
}],
output: [
{
dir: './build/esm',
exports: 'named',
format: 'esm',
interop: false
}, {
dir: './build/cjs',
exports: 'named',
format: 'cjs',
interop: false
}
],

plugins: [
babel({
babelrc: false,
exclude: 'node_modules/**',
presets: [['@babel/preset-env', { modules: false }]]
}),
].concat(plugins)
]
}, ...[
{
input: 'src/index.js',
Expand All @@ -60,31 +53,36 @@ export default [
}
}
].map((item) => {
const format = 'umd';
const format = 'iife';
return {
input: item.input,
output: {
file: `./build/${format}/${item.output.file}`,
name: item.output.name,
format: format,
exports: 'named',
extend: true
interop: false
},
plugins: [
babel({
babelrc: false,
exclude: 'node_modules/**',
presets: [['@babel/preset-env', {
targets: 'last 2 versions, ie >= 11',
corejs: '3',
useBuiltIns: 'usage'
modules: false,
}]]
}),
resolve(),
commonjs(),
minify({
comments: false,
banner: '/* vector class - MIT License */',
bannerNewLine: true
}),
visualizer({
filename: `./report/${item.output.name}.html`,
template: 'treemap'
})
].concat(plugins)
]
}
})
];
37 changes: 37 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -64,6 +64,7 @@
"rimraf": "^3.0.0",
"rollup-plugin-babel": "^4.3.3",
"rollup-plugin-babel-minify": "^9.1.0",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-visualizer": "^2.6.0",
"semantic-release": "^15.13.28",
Expand Down

0 comments on commit ecb947c

Please sign in to comment.