高级前端
前端工程化
【Q748】在 babel 编译为低版本 ES 时,为何能够编译可选链之类语法,但无法编译 API

在 babel 编译为低版本 ES 时,为何能够编译可选链之类语法,但无法编译 API

Issue 欢迎在 Gtihub Issue 中回答此问题: Issue 794 (opens in a new tab)

Author 回答者: shfshanyue (opens in a new tab)

https://q.shanyue.tech/engineering/734.html (opens in a new tab)

babel/swc 只能处理操作符,而无法处理新的 API。如果需要处理 API 兼容,则需要引入 core-js 增加垫片代码