taro
taro copied to clipboard
微信小程序反向转换报错Error: The 'decorators' plugin requires a 'decoratorsBeforeExport' option
这个特性解决了什么问题?
微信小程序反向转换为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 (
看看生成的装饰器代码有没错误,没有的话搜索一下此报错
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
没有生成代码,页面转换的时候已经报错了
+1 同样遇到 目前手动修改了 /opt/homebrew/lib/node_modules/@tarojs/cli/dist/config/babylon.js 文件解决了
['decorators',{ decoratorsBeforeExport:true }]
/cli/dist/config/babylon.js
大佬,taro convert 出现的error: slot 的值必须是一个字符串 这个错误遇到过吗
没有,已经放弃转换了
我也遇到这个问题了。。。算了吧,这个转换功能太扯犊子了,内部真的测过吗
+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
['decorators',{ decoratorsBeforeExport:true }]
+1
一样的问题。 太扯了,这种bug自己拿一个原生小程序跑一下就能发现的问题。