• babel-runtime 和 babel-polyfill


    Babel 默认只转换新的 JavaScript 语法

    babel-plugin-transform-runtime:babel打包的一个plugin,用来把babel-runtime polyfill注入到代码里

    babel-preset-es2015:ES6的语法转换,Generator的ployfill,打包代码的方式(amd,commonjs,systemjs,umd)

    babel-runtime:Generator的ployfill,ES6 polyfill 集合

    babel-polyfill:Generator的ployfill,ES6 polyfill 集合

    babel-plugin-transform-runtime
    	babel-runtime
    		core-js // ES6 polyfill
    		regenerator-runtime // Generator polyfill
    
    babel-polyfill
    	babel-runtime
    		core-js // ES6 polyfill
    		regenerator-runtime // Generator polyfill
    	regenerator-runtime // Generator polyfill
    	core-js // ES6 polyfill
    

    babel-polyfill

    Babel 默认只转换新的 JavaScript 语法,而不转换新的 API。例如,Iterator、Generator、Set、Maps、Proxy、Reflect、Symbol、Promise 等全局对象,以及一些定义在全局对象上的方法(比如 Object.assign)都不会转译。如果想使用这些新的对象和方法,必须使用 babel-polyfill,为当前环境提供一个垫片。

    babel-runtime

    babel-runtime 是为了减少重复代码而生的。babel-runtime插件能够将这些工具函数的代码转换成require语句,指向为对babel-runtime的引用。

    babel-plugin-transform-runtime

    以插件的形式在打包时引入到文件里

    指定plugin

    默认的如果使用了 babel-preset-es2015 的 preset,那么就意味着你必须要使用所有的plugin,如果浏览器已经支持了Generator,你不想做转换,你可以使用这个库 babel-preset-es2015-without-regenerator

    或者你可以自己定义plugin,把 babel-preset-es2015 里面的依赖抽取出来。自定义配置。比如这个没有 regenerator transform的babelrc配置

    {
      "presets": [],
      "plugins": [
        "babel-plugin-check-es2015-constants",
        "babel-plugin-transform-es2015-arrow-functions",
        "babel-plugin-transform-es2015-block-scoped-functions",
        "babel-plugin-transform-es2015-block-scoping",
        "babel-plugin-transform-es2015-classes",
        "babel-plugin-transform-es2015-computed-properties",
        "babel-plugin-transform-es2015-destructuring",
        "babel-plugin-transform-es2015-duplicate-keys",
        "babel-plugin-transform-es2015-for-of",
        "babel-plugin-transform-es2015-function-name",
        "babel-plugin-transform-es2015-literals",
        "babel-plugin-transform-es2015-modules-commonjs",
        "babel-plugin-transform-es2015-object-super",
        "babel-plugin-transform-es2015-parameters",
        "babel-plugin-transform-es2015-shorthand-properties",
        "babel-plugin-transform-es2015-spread",
        "babel-plugin-transform-es2015-sticky-regex",
        "babel-plugin-transform-es2015-template-literals",
        "babel-plugin-transform-es2015-typeof-symbol",
        "babel-plugin-transform-es2015-unicode-regex"
      ]
    }
    
  • 相关阅读:
    C# 实现从程序集中抽取内嵌资源文件
    git clone 显著提速,解决Github代码拉取速度缓慢问题
    C# 将List数据 导出到csv 文件
    Nginx的location匹配规则-根据url 路径重定向到不同的IP
    WinForm最小化到托盘以及托盘右键菜单
    安卓手机浏览器调试-Debug模式
    C#-Forms.Timer、Timers.Timer、Threading.Timer的比较和使用
    批处理实现批量创建快捷方式
    设计模式(六)装饰模式(转)
    设计模式(五)桥接模式(转)
  • 原文地址:https://www.cnblogs.com/xiaoniuzai/p/7009739.html
Copyright © 2020-2023  润新知