taro icon indicating copy to clipboard operation
taro copied to clipboard

Cannot use the decorators and decorators-legacy plugin together

Open wooline opened this issue 6 years ago • 3 comments

版本

taro next-rc.6

问题描述

将babel.config.js设置如下:

{
  presets: [
    ['taro', {
      framework: 'react',
      ts: true,
      loose: true,
      decoratorsBeforeExport: true,
      decoratorsLegacy: false
    }]
  ]
}

报错信息

Cannot use the decorators and decorators-legacy plugin together

补充信息

打印babel最终的plugins大致如下

[ 'decorators-legacy',
  'classProperties',
  'classPrivateProperties',
  'objectRestSpread',
  'nullishCoalescingOperator',
  'optionalChaining',
  'jsonStrings',
  'optionalCatchBinding',
  'asyncGenerators',
  'objectRestSpread',
  'dynamicImport',
  [ 'decorators', { decoratorsBeforeExport: true } ],
  'classProperties',
  'classPrivateProperties',
  ...
]

decorators-legacy与decorators重复了,decorators-legacy是babel6中的transform,babel 7不需要了吧

wooline avatar Jun 29 '20 17:06 wooline

补充一下,之所以需要这么设置是因为同时使用 decorators 和 class-properties 时,必须这样设置

wooline avatar Jun 30 '20 15:06 wooline

+1

dreamthen avatar Jul 09 '20 12:07 dreamthen

👀

NaiveCAI avatar Aug 05 '20 02:08 NaiveCAI