shfshanyue / Daily-Question

互联网大厂内推及大厂面经整理,并且每天一道面试题推送。每天五分钟,半年大厂中
https://q.shanyue.tech
4.87k stars 504 forks source link

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

Open shfshanyue opened 1 year ago

shfshanyue commented 1 year ago

https://q.shanyue.tech/engineering/734.html

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