Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.

Commit 0ce55be

Browse files
committed
build: Integrated babel into build to make bundle compatible with ES5
refers to nuxt#773
1 parent e9adc99 commit 0ce55be

11 files changed

+6974
-4512
lines changed

babel.config.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = {
2+
plugins: [
3+
['@babel/plugin-transform-runtime', { regenerator: true }], // Needed for IE9 build target
4+
],
5+
presets: [
6+
[
7+
'@babel/preset-env',
8+
{
9+
targets: {
10+
node: 'current',
11+
ie: 9,
12+
},
13+
},
14+
],
15+
],
16+
}

build/rollup.config.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import path from 'path'
22
import alias from '@rollup/plugin-alias'
3-
// import babel from '@rollup/plugin-babel'
3+
import babel from '@rollup/plugin-babel'
4+
import { DEFAULT_EXTENSIONS } from '@babel/core'
45
import commonjs from '@rollup/plugin-commonjs'
56
import nodeResolve from '@rollup/plugin-node-resolve'
67
import replace from '@rollup/plugin-replace'
@@ -62,11 +63,10 @@ function rollupConfig ({
6263
vue: 'Vue'
6364
}
6465
},
65-
external,
66+
external: [...external, /@babel\/runtime/],
6667
plugins: [
6768
replace(replaceConfig),
6869
nodeResolve(),
69-
commonjs(),
7070
ts({
7171
check: !didTS,
7272
tsconfig: r('../tsconfig.json'),
@@ -79,7 +79,17 @@ function rollupConfig ({
7979
},
8080
exclude: ['node_modules', '__tests__', 'test-dts']
8181
}
82-
})
82+
}),
83+
babel({
84+
babelHelpers: 'runtime',
85+
exclude: 'node_modules/**',
86+
extensions: [
87+
...DEFAULT_EXTENSIONS,
88+
'.ts',
89+
'.tsx'
90+
]
91+
}),
92+
commonjs()
8393
].concat(plugins)
8494
})
8595

0 commit comments

Comments
 (0)