Skip to content

Commit 6751d24

Browse files
committed
fix: correctly transpile builds
1 parent 3213227 commit 6751d24

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

scripts/rollup.config.js

+21-18
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const banner = `/**
1313
* (c) ${new Date().getFullYear()}
1414
* - Declan de Wet
1515
* - Sébastien Chopin (@Atinux)
16-
* - All the amazing contributors
16+
* - All the amazing contributors
1717
* @license MIT
1818
*/
1919
`
@@ -32,7 +32,8 @@ function rollupConfig({
3232
}
3333
}
3434

35-
if (!config.output.format || config.output.format === 'umd') {
35+
// keep simple polyfills when buble plugin is used for build
36+
if (plugins && plugins.some(p => p.name === 'buble')) {
3637
replaceConfig.values = {
3738
'const polyfill = process.env.NODE_ENV === \'test\'': 'const polyfill = true',
3839
}
@@ -49,65 +50,67 @@ function rollupConfig({
4950
plugins: [
5051
json(),
5152
nodeResolve(),
53+
commonjs(),
5254
replace(replaceConfig)
5355
].concat(plugins),
5456
})
5557
}
5658

5759
export default [
5860
// umd web build
59-
rollupConfig({
61+
{
6062
output: {
6163
file: pkg.web,
6264
},
6365
plugins: [
64-
commonjs(),
6566
buble()
6667
]
67-
}),
68+
},
6869
// minimized umd web build
69-
rollupConfig({
70+
{
7071
output: {
7172
file: pkg.web.replace('.js', '.min.js'),
7273
},
7374
plugins: [
74-
commonjs(),
7575
buble(),
7676
terser()
7777
]
78-
}),
78+
},
7979
// common js build
80-
rollupConfig({
80+
{
8181
input: 'src/index.js',
8282
output: {
8383
file: pkg.main,
8484
format: 'cjs'
8585
},
8686
plugins: [
87-
commonjs()
87+
buble()
8888
],
8989
external: Object.keys(pkg.dependencies)
90-
}),
90+
},
9191
// esm build
92-
rollupConfig({
92+
{
9393
input: 'src/index.js',
9494
output: {
9595
file: pkg.web.replace('.js', '.esm.js'),
9696
format: 'es'
9797
},
98+
plugins: [
99+
buble()
100+
],
98101
external: Object.keys(pkg.dependencies)
99-
}),
102+
},
100103
// browser esm build
101-
rollupConfig({
104+
{
102105
input: 'src/browser.js',
103106
output: {
104107
file: pkg.web.replace('.js', '.esm.browser.js'),
105108
format: 'es'
106109
},
107110
external: Object.keys(pkg.dependencies)
108-
}),
111+
},
109112
// minimized browser esm build
110-
rollupConfig({
113+
{
111114
input: 'src/browser.js',
112115
output: {
113116
file: pkg.web.replace('.js', '.esm.browser.min.js'),
@@ -117,5 +120,5 @@ export default [
117120
terser()
118121
],
119122
external: Object.keys(pkg.dependencies)
120-
})
121-
]
123+
}
124+
].map(rollupConfig)

0 commit comments

Comments
 (0)