Skip to content

Commit 71b2d52

Browse files
committed
fix: babel config for rollup
1 parent 8e15fdb commit 71b2d52

File tree

2 files changed

+26
-21
lines changed

2 files changed

+26
-21
lines changed

babel.config.js

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
module.exports = {
2-
"plugins": ["@babel/plugin-syntax-dynamic-import"],
3-
"env": {
4-
"test": {
5-
"plugins": ["dynamic-import-node"],
6-
"presets": [
7-
[ "@babel/env", {
2+
env: {
3+
test: {
4+
plugins: [
5+
'@babel/plugin-syntax-dynamic-import',
6+
'dynamic-import-node'
7+
],
8+
presets: [
9+
[ '@babel/preset-env', {
810
targets: {
9-
node: "current"
11+
node: 'current'
1012
}
1113
}]
12-
]
14+
],
1315
}
14-
},
16+
}
1517
}

scripts/rollup.config.js

+15-12
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@ const banner = `/**
1818
*/
1919
`
2020

21+
const babelConfig = () => ({
22+
presets: [
23+
['@babel/preset-env', {
24+
targets: {
25+
node: 8,
26+
ie: 9,
27+
safari: '5.1'
28+
}
29+
}]
30+
]
31+
})
32+
2133
function rollupConfig({
2234
plugins = [],
2335
...config
@@ -50,8 +62,9 @@ function rollupConfig({
5062
plugins: [
5163
json(),
5264
nodeResolve(),
65+
replace(replaceConfig),
5366
commonjs(),
54-
replace(replaceConfig)
67+
babel(babelConfig()),
5568
].concat(plugins),
5669
})
5770
}
@@ -61,18 +74,14 @@ export default [
6174
{
6275
output: {
6376
file: pkg.web,
64-
},
65-
plugins: [
66-
babel()
67-
]
77+
}
6878
},
6979
// minimized umd web build
7080
{
7181
output: {
7282
file: pkg.web.replace('.js', '.min.js'),
7383
},
7484
plugins: [
75-
babel(),
7685
terser()
7786
]
7887
},
@@ -83,9 +92,6 @@ export default [
8392
file: pkg.main,
8493
format: 'cjs'
8594
},
86-
plugins: [
87-
babel()
88-
],
8995
external: Object.keys(pkg.dependencies)
9096
},
9197
// esm build
@@ -95,9 +101,6 @@ export default [
95101
file: pkg.web.replace('.js', '.esm.js'),
96102
format: 'es'
97103
},
98-
plugins: [
99-
babel()
100-
],
101104
external: Object.keys(pkg.dependencies)
102105
},
103106
// browser esm build

0 commit comments

Comments
 (0)