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

taro convert转换小程序的官方demo后运行dev:weapp报错 Unexpected "@" #13007

Closed
fantasy525 opened this issue Dec 20, 2022 · 14 comments · Fixed by #13012 or #13055
Closed

taro convert转换小程序的官方demo后运行dev:weapp报错 Unexpected "@" #13007

fantasy525 opened this issue Dec 20, 2022 · 14 comments · Fixed by #13012 or #13055
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Milestone

Comments

@fantasy525
Copy link

相关平台

微信小程序

复现仓库

https://github.com/fantasy525/taro_convert_weapp.git
小程序基础库: 2.28.1
使用框架: React

复现步骤

1.克隆代码
2.yarn
3.yarn dev:weapp

期望结果

编译成功,打开小程序能看到

实际结果

[ERROR] Unexpected "@"

src/pages/logs/logs.js:9:0:
  9 │ @withWeapp({
    ╵ ^

✘ [ERROR] Unexpected "@"

src/app.js:7:0:
  7 │ @withWeapp({
    ╵ ^

✘ [ERROR] Unexpected "@"

src/pages/index/index.js:10:0:

环境信息

Taro v3.5.7


  Taro CLI 3.5.7 environment info:
    System:
      OS: macOS 12.5.1
      Shell: 5.8.1 - /bin/zsh
    Binaries:
      Node: 16.17.1 - /usr/local/bin/node
      Yarn: 1.22.19 - /usr/local/bin/yarn
      npm: 8.15.0 - /usr/local/bin/npm
    npmPackages:
      @tarojs/cli: 3.5.7 => 3.5.7 
      @tarojs/components: 3.5.7 => 3.5.7 
      @tarojs/helper: 3.5.7 => 3.5.7 
      @tarojs/plugin-framework-react: 3.5.7 => 3.5.7 
      @tarojs/plugin-platform-alipay: 3.5.7 => 3.5.7 
      @tarojs/plugin-platform-jd: 3.5.7 => 3.5.7 
      @tarojs/plugin-platform-qq: 3.5.7 => 3.5.7 
      @tarojs/plugin-platform-swan: 3.5.7 => 3.5.7 
      @tarojs/plugin-platform-tt: 3.5.7 => 3.5.7 
      @tarojs/plugin-platform-weapp: 3.5.7 => 3.5.7 
      @tarojs/react: 3.5.7 => 3.5.7 
      @tarojs/router: 3.5.7 => 3.5.7 
      @tarojs/runtime: 3.5.7 => 3.5.7 
      @tarojs/shared: 3.5.7 => 3.5.7 
      @tarojs/taro: 3.5.7 => 3.5.7 
      @tarojs/taro-h5: 3.5.7 => 3.5.7 
      @tarojs/webpack5-runner: 3.5.7 => 3.5.7 
      @tarojs/with-weapp: ^3.5.7 => 3.5.10 
      babel-preset-taro: 3.5.7 => 3.5.7 
      eslint-config-taro: 3.5.7 => 3.5.7 
      react: ^18.0.0 => 18.2.0 

@taro-bot2 taro-bot2 bot added F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x labels Dec 20, 2022
@fantasy525
Copy link
Author

补充一个问题,我的电脑是 mac M1 的cpu,安装的node-sass不支持,报错

Error: Node Sass does not yet support your current environment: OS X Unsupported architecture (arm64) with Unsupported runtime (93) For more information on which environments are supported please see:
https://github.com/sass/node-sass/releases/tag/v4.14.1

@yoyo837
Copy link
Contributor

yoyo837 commented Dec 20, 2022

应该切换到sass, Dart Sass

@fantasy525
Copy link
Author

应该切换到sass, Dart Sass

是说让taro内部切换吗还是我自己切换?

@yoyo837
Copy link
Contributor

yoyo837 commented Dec 21, 2022

内部

@yoyo837
Copy link
Contributor

yoyo837 commented Dec 21, 2022

补充一个问题,我的电脑是 mac M1 的cpu,安装的node-sass不支持,报错

Error: Node Sass does not yet support your current environment: OS X Unsupported architecture (arm64) with Unsupported runtime (93) For more information on which environments are supported please see: https://github.com/sass/node-sass/releases/tag/v4.14.1

你仓库没看见这个错误呢

@yoyo837
Copy link
Contributor

yoyo837 commented Dec 21, 2022

image

@yoyo837
Copy link
Contributor

yoyo837 commented Dec 21, 2022

初步看babel-preset-taro/index.js 没执行到就已经抛出错误了

@Chen-jj
Copy link
Contributor

Chen-jj commented Dec 22, 2022

补充一个问题,我的电脑是 mac M1 的cpu,安装的node-sass不支持,报错

Error: Node Sass does not yet support your current environment: OS X Unsupported architecture (arm64) with Unsupported runtime (93) For more information on which environments are supported please see: https://github.com/sass/node-sass/releases/tag/v4.14.1

@tarojs/webpack5-runner 依赖的是 sass,安装依赖后观察 lockfile 也没找到 node-sass,不清楚是哪里来的,可以你要自行排查下。

@Chen-jj
Copy link
Contributor

Chen-jj commented Dec 23, 2022

@fantasy525 感谢 @yoyo837 的提示,报错出在依赖预编译阶段,还没到 Webpack 打包阶段。依赖预编译时会使用 esbuild 进行 bundle,而 esbuild 只在 tsx loader 中实现了 decoratorhttps://github.com/evanw/esbuild/issues/104#issuecomment-1025061506),因此需要把 .js .jsx 都配置为使用 esbuild 的 tsx loader。

@yoyo837
Copy link
Contributor

yoyo837 commented Dec 23, 2022

@fantasy525 感谢 @yoyo837 的提示,报错出在依赖预编译阶段,还没到 Webpack 打包阶段。依赖预编译时会使用 esbuild 进行 bundle,而 esbuild 只在 tsx loader 中实现了 decoratorhttps://github.com/evanw/esbuild/issues/104#issuecomment-1025061506),因此需要把 .js .jsx 都配置为使用 esbuild 的 tsx loader。

666

@fantasy525
Copy link
Author

@Chen-jj 发布新版本后关闭

@tourze
Copy link
Contributor

tourze commented Dec 24, 2022

等发布中。。。刚好遇到这个问题

@fantasy525
Copy link
Author

fantasy525 commented Dec 25, 2022

image

image

是哪个版本从node-sass切换到sass了?

@fantasy525
Copy link
Author

补充一个问题,我的电脑是 mac M1 的cpu,安装的node-sass不支持,报错
Error: Node Sass does not yet support your current environment: OS X Unsupported architecture (arm64) with Unsupported runtime (93) For more information on which environments are supported please see: https://github.com/sass/node-sass/releases/tag/v4.14.1

@tarojs/webpack5-runner 依赖的是 sass,安装依赖后观察 lockfile 也没找到 node-sass,不清楚是哪里来的,可以你要自行排查下。

嗨,我发现我把taro相关的包升级到最新版本就没node-sass的问题了
@tarojs/mini-runner,@tarojs/webpack-runner,babel-preset-taro
这三个都升级到3.5.10,之前的版本有这个问题

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