Skip to content

Commit

Permalink
fix: correctly transpile builds
Browse files Browse the repository at this point in the history
  • Loading branch information
pimlie committed Jun 10, 2019
1 parent 3213227 commit 6751d24
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions scripts/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const banner = `/**
* (c) ${new Date().getFullYear()}
* - Declan de Wet
* - Sébastien Chopin (@Atinux)
* - All the amazing contributors
* - All the amazing contributors
* @license MIT
*/
`
Expand All @@ -32,7 +32,8 @@ function rollupConfig({
}
}

if (!config.output.format || config.output.format === 'umd') {
// keep simple polyfills when buble plugin is used for build
if (plugins && plugins.some(p => p.name === 'buble')) {
replaceConfig.values = {
'const polyfill = process.env.NODE_ENV === \'test\'': 'const polyfill = true',
}
Expand All @@ -49,65 +50,67 @@ function rollupConfig({
plugins: [
json(),
nodeResolve(),
commonjs(),
replace(replaceConfig)
].concat(plugins),
})
}

export default [
// umd web build
rollupConfig({
{
output: {
file: pkg.web,
},
plugins: [
commonjs(),
buble()
]
}),
},
// minimized umd web build
rollupConfig({
{
output: {
file: pkg.web.replace('.js', '.min.js'),
},
plugins: [
commonjs(),
buble(),
terser()
]
}),
},
// common js build
rollupConfig({
{
input: 'src/index.js',
output: {
file: pkg.main,
format: 'cjs'
},
plugins: [
commonjs()
buble()
],
external: Object.keys(pkg.dependencies)
}),
},
// esm build
rollupConfig({
{
input: 'src/index.js',
output: {
file: pkg.web.replace('.js', '.esm.js'),
format: 'es'
},
plugins: [
buble()
],
external: Object.keys(pkg.dependencies)
}),
},
// browser esm build
rollupConfig({
{
input: 'src/browser.js',
output: {
file: pkg.web.replace('.js', '.esm.browser.js'),
format: 'es'
},
external: Object.keys(pkg.dependencies)
}),
},
// minimized browser esm build
rollupConfig({
{
input: 'src/browser.js',
output: {
file: pkg.web.replace('.js', '.esm.browser.min.js'),
Expand All @@ -117,5 +120,5 @@ export default [
terser()
],
external: Object.keys(pkg.dependencies)
})
]
}
].map(rollupConfig)

0 comments on commit 6751d24

Please sign in to comment.