message: refactor: rollup config
diff: +import babel from '@rollup/plugin-babel'
  import autoprefixer from 'autoprefixer'
  import commonjs from 'rollup-plugin-commonjs'
  import resolve from 'rollup-plugin-node-resolve'
  -import external from 'rollup-plugin-peer-deps-external'
  import postcss from 'rollup-plugin-postcss'
  +import sourceMaps from 'rollup-plugin-sourcemaps'
  import typescript from 'rollup-plugin-typescript2'
  -import pkg from './package.json'
  +const pkg = require('./package.json')
  -export default {
  - input: 'src/index.tsx',
  - output: [
  - {
  - file: pkg.main,
  - format: 'cjs',
  - sourcemap: true,
  +const input = 'src/index.ts'
  +const extensions = ['.ts', '.tsx']
  +
  +const plugins = [
  + typescript({
  + tsconfigDefaults: {
  + exclude: [
  + // all TS test files, regardless whether co-located or in test/ etc
  + '**/*.spec.ts',
  + '**/*.test.ts',
  + '**/*.spec.tsx',
  + '**/*.test.tsx',
  + ],
  + compilerOptions: {
  + sourceMap: true,
  + declaration: true,
  + jsx: 'react',
  + },
  + tsconfigOverride: {
  + compilerOptions: {
  + // TS -> esnext, then leave the rest to babel-preset-env
  + target: 'esnext',
  },
  - {
  - file: pkg.module,
  - format: 'es',
  - sourcemap: true,
  },
  - ],
  - plugins: [
  - external(),
  - resolve({
  - browser: true,
  - }),
  - typescript(),
  - commonjs({
  - include: /node_modules/,
  - exclude: ['**/*.stories.js'],
  - namedExports: {
  - 'node_modules/react/react.js': [
  - 'Children',
  - 'Component',
  - 'PropTypes',
  - 'createElement',
  - ],
  - 'node_modules/react-dom/index.js': ['render'],
  },
  + typescript: require('typescript'),
  }),
  postcss({
  extract: false,
  @@ -46,5 +41,50 @@ export default {
  use: ['sass'],
  plugins: [autoprefixer()],
  }),
  + resolve({
  + mainFields: ['module', 'main', 'browser'],
  + extensions: ['.js', '.jsx'],
  + }),
  + commonjs(),
  + sourceMaps(),
  + babel({
  + extensions,
  + babelHelpers: 'runtime',
  + include: 'src/**/*',
  + exclude: 'node_modules/**',
  + presets: [
  + [
  + '@babel/preset-env',
  + {
  + modules: false,
  + loose: true,
  + },
  + ],
  + ],
  + plugins: ['@babel/plugin-transform-runtime'],
  + }),
  +]
  +
  +const outputOptions = {
  + sourcemap: true,
  + freeze: false,
  + esModule: true,
  +}
  +
  +export default {
  + input,
  + output: [
  + {
  + file: pkg.module,
  + format: 'es',
  + ...outputOptions,
  + },
  + {
  + file: pkg.main,
  + format: 'cjs',
  + ...outputOptions,
  + },
  ],
  + external: Object.keys(pkg.peerDependencies),
  + plugins,
  }
  