Skip to content
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

[3.6.2] @taro/helper 中的 swc_plugin_define_config.wasm 插件对 app.config.js 文件的转换有影响 #13538

Closed
TralafalgarV opened this issue Mar 29, 2023 · 6 comments · Fixed by #13737
Assignees
Labels
F-react Framework - React good first issue Good for newcomers T-weapp Target - 编译到微信小程序 V-3 Version - 3.x

Comments

@TralafalgarV
Copy link

相关平台

微信小程序

复现仓库

https://github.com/TralafalgarV/bug-taro-swc-demo.git
小程序基础库: 2.12.3
使用框架: React

复现步骤

复现流程

安装依赖

pnpm install

修改 swc_plugin_define_config.wasm 绝对路径

修改 swc-register.js 文件的第 69 行代码,根据实际情况填写 swc_plugin_define_config 插件的绝对路径

执行命令

node swc-register.js

查看结果

查看 output.js 文件的第 93 行

转换前:
subPackages: pathsMap.subPackages.map((item) => {
    return {
      root: item.root,
      pages: Object.values(item.pages),
    };
  }),

转换后:
subPackages: pathsMap.subPackages.map(function(item) {}),

从上面可以看出,app.config.js 文件被 swc 转换后,箭头函数内部的代码被清空了。

但是如果注释掉 swc-register.js 文件 第 67 ~~ 72 行的 swc_plugin_define_config.wasm 这个插件的话,输出的转换内容就是正常的,没有问题。

结论

怀疑 swc_plugin_define_config.wasm 这个插件的实现有问题。

期望结果

通过 swc 转换的 app.config.js 文件,功能正常。

实际结果

通过 swc 转换的 app.config.js 文件,箭头函数中的代码被清空。

环境信息

Taro CLI 3.6.1 environment info:
    System:
      OS: macOS 13.0.1
      Shell: 5.8.1 - /bin/zsh
    Binaries:
      Node: 16.19.0 - ~/.nvm/versions/node/v16.19.0/bin/node
      Yarn: 1.22.19 - ~/.nvm/versions/node/v16.19.0/bin/yarn
      npm: 8.19.3 - ~/.nvm/versions/node/v16.19.0/bin/npm
    npmPackages:
      @tarojs/cli: 3.6.1 => 3.6.1 
      @tarojs/components: 3.6.1 => 3.6.1 
      @tarojs/helper: 3.6.1 => 3.6.1 
      @tarojs/plugin-framework-react: 3.6.1 => 3.6.1 
      @tarojs/plugin-platform-alipay: 3.6.1 => 3.6.1 
      @tarojs/plugin-platform-jd: 3.6.1 => 3.6.1 
      @tarojs/plugin-platform-qq: 3.6.1 => 3.6.1 
      @tarojs/plugin-platform-swan: 3.6.1 => 3.6.1 
      @tarojs/plugin-platform-tt: 3.6.1 => 3.6.1 
      @tarojs/plugin-platform-weapp: 3.6.1 => 3.6.1 
      @tarojs/react: 3.6.1 => 3.6.1 
      @tarojs/router: 3.6.1 => 3.6.1 
      @tarojs/runtime: 3.6.1 => 3.6.1 
      @tarojs/shared: 3.6.1 => 3.6.1 
      @tarojs/taro: 3.6.1 => 3.6.1 
      @tarojs/taro-h5: 3.6.1 => 3.6.1 
      @tarojs/webpack5-runner: 3.6.1 => 3.6.1 
      babel-preset-taro: 3.6.1 => 3.6.1 
      eslint-config-taro: 3.6.1 => 3.6.1 
      react: ^18.2.0 => 18.2.0 
      taro-ui: ^3.1.0-beta.4 => 3.1.0-beta.4 
@taro-bot2 taro-bot2 bot added F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x labels Mar 29, 2023
@Chen-jj Chen-jj added the good first issue Good for newcomers label Mar 29, 2023
@Chen-jj
Copy link
Contributor

Chen-jj commented Mar 29, 2023

之前收到过反馈,怀疑是 swc 的版本问题导致需要再调查一下

@TralafalgarV
Copy link
Author

TralafalgarV commented Mar 29, 2023

之前收到过反馈,怀疑是 swc 的版本问题导致需要再调查一下

感谢大佬回复。
我按照这个 #issue 将 @swc/core 版本锁定为 1.3.6 确实可以解决问题。但是不明白的是,为什么高版本的 @swc/core 却不行了?

@Chen-jj Chen-jj self-assigned this Mar 30, 2023
@ccqgithub
Copy link

遇到同样的问题,app.config.ts里不能用箭头函数~

@joket1999
Copy link

joket1999 commented May 15, 2023

我也遇到这个问题,问题产生的原因是重装了@taro/cli,但是项目里的node_modules没有没动过啊。
@swc/core换成 1.3.6也不行:
thread '<unnamed>' panicked at 'called Result::unwrap()on anErrvalue: LayoutError', /Users/chenjiajian/.cargo/registry/src/github.com-1ecc6299db9ec823/rkyv-0.7.37/src/impls/core/mod.rs:265:67 note: run withRUST_BACKTRACE=1environment variable to display a backtrace thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("~/Documents/min-app/src/app.config.js")'

有rust的报错,路径也是感人“ /Users/chenjiajian/”,这是作者?

@GGTMiku
Copy link

GGTMiku commented May 22, 2023

我也是,项目跑不起来了,夭寿啊

@NiniYing
Copy link

我也遇到这个问题,请问大佬这个报错最终如何解决的?
thread '' panicked at 'called Result::unwrap()on anErrvalue: LayoutError', /Users/chenjiajian/.cargo/registry/src/github.com-1ecc6299db9ec823/rkyv-0.7.37/src/impls/core/mod.rs:265:67 note: run withRUST_BACKTRACE=1environment variable to display a backtrace thread '' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("~/Documents/min-app/src/app.config.js")'

有rust的报错,路径也是感人“ /Users/chenjiajian/”,这是作者?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React good first issue Good for newcomers T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants