1

装饰器语法支持

webpack 搭建文档:https://webpack.eleven.net.cn
  1. 安装依赖

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

    {
      assumptions: {
        /**
         * https://babeljs.io/docs/en/assumptions#setpublicclassfields
        *
        * 装饰器的 legancy: true,依赖此配置
        *  - https://babeljs.io/docs/en/babel-plugin-proposal-decorators#legacy
        */
        setPublicClassFields: true,
      },
      "presets": [],
      "plugins": [
        [
          // @babel/plugin-proposal-decorators 需要在 @babel/plugin-proposal-class-properties 之前
          '@babel/plugin-proposal-decorators',
          {
            legacy: true, // 推荐
          },
        ],
        ['@babel/plugin-proposal-class-properties'],
      ]
    }

import - 动态导入支持

  1. 安装依赖

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

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

Eleven
381 声望62 粉丝