【发布时间】:2020-09-30 21:02:44
【问题描述】:
create-react-app 默认使用browserslist,但我认为它仅适用于*.js 文件(我不太确定),对于*.ts 没有区别。
我的环境(由create-react-app生成):
- webpack:~4.29.6
- 反应:~16.12.0
- 打字稿:~3.7.2
项目代码仅包含*.ts / *.tsx 文件。
我尝试通过以下方式添加Object.entries polyfill:
- 通过添加
IE 9、chrome >20等来更改package.json中的browserslist- 但无济于事(dist 未更改) - 将
tsconfig.json中的compilerOptions.target更改为es5- 但无济于事(dist 未更改) - 在
tsconfig.json中添加compilerOptions.lib新值:es5、es6、es7等... - 但无济于事(dist 未更改)
只添加import 'react-app-polyfill/stable'; 给我Object.entries polyfill,但有大约 600kb 的其他 polyfill :(
问题:
- create-react-app 项目中的browserslist 是否仅用于
*.js文件? - 目前是否没有办法使用browserslist 自动添加polyfills 来编译TypeScript 项目?
- browserslist 对 TypeScript 项目完全没用吗?
【问题讨论】:
标签: reactjs typescript webpack create-react-app