taro icon indicating copy to clipboard operation
taro copied to clipboard

微信小程序反向转换报错Error: The 'decorators' plugin requires a 'decoratorsBeforeExport' option

Open chenwebber opened this issue 3 years ago • 9 comments

这个特性解决了什么问题?

微信小程序反向转换为taro, 以便多端开发,小程序用到了behaviors: ['wx://component-export']不知有无影响,原小程序没有使用decorator

这个 API 长什么样?

Error: The 'decorators' plugin requires a 'decoratorsBeforeExport' option, whose value must be a boolean. If you are migrating from Babylon/Babel 6 or want to use the old decorators proposal, you should use the 'decorators-legacy' plugin instead of 'decorators'. at validatePlugins (/usr/local/lib/node_modules/@tarojs/cli/node_modules/@[email protected]@@babel/parser/src/plugin-utils.js:87:13) at getParser (/usr/local/lib/node_modules/@tarojs/cli/node_modules/@[email protected]@@babel/parser/src/index.js:83:5) at parse (/usr/local/lib/node_modules/@tarojs/cli/node_modules/@[email protected]@@babel/parser/src/index.js:58:12) at parseWithCodeFrame (/usr/local/lib/node_modules/@tarojs/cli/node_modules/@[email protected]@@babel/template/lib/parse.js:175:30) at parseAndBuildMetadata (/usr/local/lib/node_modules/@tarojs/cli/node_modules/@[email protected]@@babel/template/lib/parse.js:36:15) at /usr/local/lib/node_modules/@tarojs/cli/node_modules/@[email protected]@@babel/template/lib/string.js:19:50 at /usr/local/lib/node_modules/@tarojs/cli/node_modules/@[email protected]@@babel/template/lib/builder.js:75:14 at /usr/local/lib/node_modules/@tarojs/cli/src/convertor/index.ts:352:20 at Set.forEach () at exit (/usr/local/lib/node_modules/@tarojs/cli/src/convertor/index.ts:345:29) ============= at /usr/local/lib/node_modules/@tarojs/cli/src/convertor/index.ts:349:27 at Set.forEach () at exit (/usr/local/lib/node_modules/@tarojs/cli/src/convertor/index.ts:345:29) at NodePath.call (/usr/local/lib/node_modules/@tarojs/cli/node_modules/@[email protected]@@babel/traverse/lib/path/context.js:53:20) at NodePath.call (/usr/local/lib/node_modules/@tarojs/cli/node_modules/@[email protected]@@babel/traverse/lib/path/context.js:40:17) at NodePath.visit (/usr/local/lib/node_modules/@tarojs/cli/node_modules/@[email protected]@@babel/traverse/lib/path/context.js:109:8) at TraversalContext.visitQueue (/usr/local/lib/node_modules/@tarojs/cli/node_modules/@[email protected]@@babel/traverse/lib/context.js:103:16) at TraversalContext.visitSingle (/usr/local/lib/node_modules/@tarojs/cli/node_modules/_@[email protected]@@babel/traverse/lib/context.js:77:19)

chenwebber avatar Jan 21 '22 10:01 chenwebber

看看生成的装饰器代码有没错误,没有的话搜索一下此报错

https://www.google.com/search?q=The+%27decorators%27+plugin+requires+a+%27decoratorsBeforeExport%27+option&oq=The+%27decorators%27+plugin+requires+a+%27decoratorsBeforeExport%27+option&aqs=chrome..69i57j69i61.308j0j1&sourceid=chrome&ie=UTF-8

Chen-jj avatar Jan 24 '22 02:01 Chen-jj

image 没有生成代码,页面转换的时候已经报错了

chenwebber avatar Jan 28 '22 07:01 chenwebber

+1 同样遇到 目前手动修改了 /opt/homebrew/lib/node_modules/@tarojs/cli/dist/config/babylon.js 文件解决了

['decorators',{ decoratorsBeforeExport:true }]

yujingwyh avatar Feb 10 '22 02:02 yujingwyh

/cli/dist/config/babylon.js

大佬,taro convert 出现的error: slot 的值必须是一个字符串 这个错误遇到过吗

slogeor avatar Feb 23 '22 02:02 slogeor

没有,已经放弃转换了

yujingwyh avatar Feb 23 '22 03:02 yujingwyh

我也遇到这个问题了。。。算了吧,这个转换功能太扯犊子了,内部真的测过吗

webpangxing avatar Mar 17 '22 09:03 webpangxing

+1 同样遇到 目前手动修改了 /opt/homebrew/lib/node_modules/@tarojs/cli/dist/config/babylon.js 文件解决了

['decorators',{ decoratorsBeforeExport:true }]

这个插件要放到最前面,放后面还不行,本人亲测有效。改完之后的样子: "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const config = { sourceType: 'module', plugins: [ ['decorators',{ decoratorsBeforeExport:true }], 'typescript', 'classProperties', 'jsx', 'asyncGenerators', 'objectRestSpread', 'decorators', 'dynamicImport' ] }; exports.default = config; //# sourceMappingURL=babylon.js.map

jackzhujie avatar Apr 11 '22 07:04 jackzhujie

['decorators',{ decoratorsBeforeExport:true }]

+1

gemxx avatar Jun 21 '22 10:06 gemxx

一样的问题。 太扯了,这种bug自己拿一个原生小程序跑一下就能发现的问题。

udyk-dev avatar Sep 05 '22 08:09 udyk-dev