|
1 | 1 | import path from 'path' |
| 2 | +import babel from '@rollup/plugin-babel' |
2 | 3 | import resolve from '@rollup/plugin-node-resolve' |
3 | 4 | import filesize from 'rollup-plugin-filesize' |
4 | | -import typescript from '@rollup/plugin-typescript' |
5 | 5 |
|
6 | 6 | const root = process.platform === 'win32' ? path.resolve('/') : '/' |
7 | 7 | const external = (id) => !id.startsWith('.') && !id.startsWith(root) |
8 | 8 | const extensions = ['.js', '.jsx', '.ts', '.tsx'] |
9 | 9 |
|
| 10 | +const getBabelOptions = () => ({ |
| 11 | + babelrc: false, |
| 12 | + extensions, |
| 13 | + exclude: '**/node_modules/**', |
| 14 | + babelHelpers: 'runtime', |
| 15 | + presets: [ |
| 16 | + [ |
| 17 | + '@babel/preset-env', |
| 18 | + { |
| 19 | + targets: '> 1%, not dead, not ie 11, not op_mini all', |
| 20 | + }, |
| 21 | + ], |
| 22 | + '@babel/preset-react', |
| 23 | + '@babel/preset-typescript', |
| 24 | + ], |
| 25 | + plugins: [['@babel/transform-runtime', { regenerator: false, useESModules: true }]], |
| 26 | +}) |
| 27 | + |
10 | 28 | export default [ |
11 | 29 | { |
12 | 30 | input: `./src/index.tsx`, |
13 | 31 | output: { file: `dist/index.js`, format: 'esm' }, |
14 | 32 | external, |
15 | | - plugins: [typescript(), resolve({ extensions }), filesize()], |
| 33 | + plugins: [babel(getBabelOptions()), resolve({ extensions }), filesize()], |
16 | 34 | }, |
17 | 35 | { |
18 | 36 | input: `./src/index.tsx`, |
19 | 37 | output: { file: `dist/index.cjs`, format: 'cjs' }, |
20 | 38 | external, |
21 | | - plugins: [typescript(), resolve({ extensions }), filesize()], |
| 39 | + plugins: [babel(getBabelOptions()), resolve({ extensions }), filesize()], |
22 | 40 | }, |
23 | 41 | ] |
0 commit comments