Babel-7-转码七-装饰器语法动态导入

装饰器语法支持

  1. 安装依赖

    yarn add @babel/plugin-proposal-decorators @babel/plugin-proposal-class-properties -D
  2. .babelrc 增加配置

    {
      "presets": [],
      "plugins": [
        [
          "@babel/plugin-proposal-decorators",  // @babel/plugin-proposal-decorators需要在@babel/plugin-proposal-class-properties之前
          {
            "legacy": true // 推荐
          }
        ],
        [
          "@babel/plugin-proposal-class-properties",
          {
            "loose": true // babel编译时,对class的属性采用赋值表达式,而不是Object.defineProperty(更简洁)
          }
        ]
      ]
    }

import – 动态导入支持

  1. 安装依赖

    yarn add @babel/plugin-syntax-dynamic-import -D
  2. .babelrc 文件增加配置

    {
      "presets": [],
      "plugins": [
        "@babel/plugin-syntax-dynamic-import",
      ]
    }

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理