New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
【Taro v3.5.6】将页面配置赋值给变量,然后导出,编译会报错 #12674
Comments
该不会把js文件内容按 |
使用 PS D:\Gitlab\taro-market> npm run dev:tgj:weapp
> taro-market@1.0.0 dev:tgj:weapp
> cross-env APP_ENV=tgj npm run build:weapp -- --watch
> taro-market@1.0.0 build:weapp
> taro build --type weapp "--watch"
👽 Taro v3.5.7
Tips:
1. 预览模式生成的文件较大,设置 NODE_ENV 为 production 可以开启压缩。
Example:
$ set NODE_ENV=production && taro build --type weapp --watch
thread '<unnamed>' panicked at 'index out of bounds: the len is 1 but the index is 1', C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\swc_common-0.29.10\src\syntax_pos\hygiene.rs:580:34note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
failed to handle: index out of bounds: the len is 1 but the index is 1
failed to handle: index out of bounds: the len is 1 but the index is 1
node:internal/process/promises:279
triggerUncaughtException(err, true /* fromPromise */);
^
Error: failed to handle: index out of bounds: the len is 1 but the index is 1
at Compiler.transformSync (D:\Gitlab\taro-market\node_modules\@swc\core\index.js:241:29)
at Compiler.transformSync (D:\Gitlab\taro-market\node_modules\@swc\core\index.js:239:29)
at Object.transformSync (D:\Gitlab\taro-market\node_modules\@swc\core\index.js:348:21)
at compile (D:\Gitlab\taro-market\node_modules\@swc\register\lib\node.js:76:22)
at compileHook (D:\Gitlab\taro-market\node_modules\@swc\register\lib\node.js:91:16)
at Module._compile (D:\Gitlab\taro-market\node_modules\pirates\lib\index.js:130:29)
at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at newLoader (C:\Users\Sprin\AppData\Roaming\npm\node_modules\@tarojs\cli\node_modules\pirates\lib\index.js:141:7)
at Object.newLoader [as .js] (D:\Gitlab\taro-market\node_modules\pirates\lib\index.js:141:7)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at readConfig (D:\Gitlab\taro-market\node_modules\@tarojs\helper\src\utils.ts:659:37)
at TaroMiniPlugin.compileFile (D:\Gitlab\taro-market\node_modules\@tarojs\mini-runner\src\plugins\MiniPlugin.ts:669:34)
at TaroMiniPlugin.getAppConfig (D:\Gitlab\taro-market\node_modules\@tarojs\mini-runner\src\plugins\MiniPlugin.ts:519:10) {
code: 'GenericFailure'
}
PS D:\Gitlab\taro-market> |
确实奇怪,我新建全新项目,修改 // app.config.js
const config = {
pages: ["pages/index/index"],
window: {
backgroundTextStyle: "light",
navigationBarBackgroundColor: "#fff",
navigationBarTitleText: "WeChat",
navigationBarTextStyle: "black",
},
};
export default config; PS D:\demo\myapp> npm run dev:weapp
> myapp@1.0.0 dev:weapp
> npm run build:weapp -- --watch
> myapp@1.0.0 build:weapp
> taro build --type weapp "--watch"
👽 Taro v3.5.7
Tips:
1. 预览模式生成的文件较大,设置 NODE_ENV 为 production 可以开启压缩。
Example:
$ set NODE_ENV=production && taro build --type weapp --watch
2. 建议开启持久化缓存功能,能有效提升二次编译速度,详情请参考: https://docs.taro.zone/docs/config-detail#cache。
thread '<unnamed>' panicked at 'index out of bounds: the len is 1 but the index is 1', C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\swc_common-0.29.10\src\syntax_pos\hygiene.rs:580:34note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
D:\demo\myapp\node_modules\@swc\core\index.js:241
return bindings.transformSync(isModule ? JSON.stringify(src) : src, isModule, toBuffer(newOptions));
^
Error: failed to handle: index out of bounds: the len is 1 but the index is 1
at Compiler.transformSync (D:\demo\myapp\node_modules\@swc\core\index.js:241:29)
at Compiler.transformSync (D:\demo\myapp\node_modules\@swc\core\index.js:239:29)
at Object.transformSync (D:\demo\myapp\node_modules\@swc\core\index.js:348:21)
at compile (D:\demo\myapp\node_modules\@swc\register\lib\node.js:76:22)
at compileHook (D:\demo\myapp\node_modules\@swc\register\lib\node.js:91:16)
at Module._compile (D:\demo\myapp\node_modules\pirates\lib\index.js:130:29)
at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Object.newLoader [as .js] (D:\demo\myapp\node_modules\pirates\lib\index.js:141:7)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12) {
code: 'GenericFailure'
} |
@tarojs/helper 包的 createSwcRegister 方法并不能完全替代 createBabelRegister,我看缺挺多plugins 的。 |
遇到了同样问题 |
问题出在以 JS 编写的 swc 自定义插件上。 目前可以用 resolution 配置项去锁 @swc/core 的版本:swc-project/swc#6255 |
@Elliott-Hu swc 把 babel 的插件都撸了遍(以内置实现+选项开启的方式),挺全的了:https://swc.rs/docs/migrating-from-babel
|
|
Taro v3.5.8 将使用 rust 插件代替 js 插件,可以绕过此问题。 |
已升级 3.5.8,仍然报该错,入口config文件直接使用json没有问题,js动态生成config就会报错 |
已升级3.5.8,仍然存在这个问题
|
还没发布的,这周 3.5.9 带出去 |
3.5.9版本还是会报这个错 thread '' panicked at 'index out of bounds: the len is 1 but the index is 1', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc_common-0.29.16/src/syntax_pos/hygiene.rs:580:34 |
3.5.9会报这个错误,系统是centos6
|
请问解决了吗,遇到一样问题 |
3.5.9 遗漏了这个特性,需要 3.5.10~ |
我3.5.10 一样的 |
【Taro v3.5.6】将页面配置赋值给变量,然后导出,编译会报错 #12674 NervJS/taro#12674
相关平台
微信小程序
复现仓库
https://github.com/qiuxiyu/taro_issue_demo/blob/main/myApp.zip
小程序基础库: 2.11.2
使用框架: React
使用 Taro cli 版本:3.5.6
复现步骤
0. 安装 3.5.6 版本的 Taro cli
1. 执行命令行,初始化项目:
2. 修改 myApp/src/pages/index/index.config.js 的内容:
------------ before ------------
------------ after ------------
3. 执行命令行,编译项目:
期望结果
编译成功且运行正常,不要报错
实际结果
编译报错,错误信息为:
环境信息
The text was updated successfully, but these errors were encountered: