1.babel-plugin-transform-runtime和babel-runtime的区别
babel-plugin-transform-runtime 实际上是依赖babel-runtime
因为babel编译es6到es5的过程中,babel-plugin-transform-runtime这个插件会自动
polyfill es5不支持的特性,我们只需要import Promise from 'babel-runtime/core-js/promise'即可,这样不仅避免污染全局对象,而且可以减少不必要的代码。babel-runtime和babel-plugin-transform-runtime的区别是,相当一前者是手动挡而后者是自动挡,每当要转译一个api时都要手动加上require('babel-runtime'),
而babel-plugin-transform-runtime会由工具自动添加,主要的功能是为api提供沙箱的垫片方案,不会污染全局的api,因此适合用在第三方的开发产品中。
2.babel-runtime和babel-plugin-transform-runtime的区别
babel-polyfill则是通过改写全局prototype的方式实现,比较适合单独运行的项目
开启babel-polyfill的方式,可以直接在代码中require,或者在webpack的entry中添加,
但是babel-polyfill会有近100K,打包后代码冗余量比较大,
复制代码