使用@rollup/plugin-typescript插件代替Rollup的官方TypeScript插件,并在Babel中使用@babel/preset-typescript插件。
示例代码:
// rollup.config.js import typescript from '@rollup/plugin-typescript'; import babel from '@rollup/plugin-babel';
export default { input: 'src/index.ts', output: { file: 'dist/bundle.js', format: 'cjs' }, plugins: [ typescript(), babel({ presets: [ '@babel/preset-env', '@babel/preset-typescript' ] }) ] };