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

monorepo项目和ts的declare语法一起用导致报错:ModuleParseError: Module parse failed #15763

Closed
Wyatex opened this issue May 22, 2024 · 2 comments
Labels
F-vue3 Framework - Vue 3 T-weapp Target - 编译到微信小程序 V-3 Version - 3.x

Comments

@Wyatex
Copy link

Wyatex commented May 22, 2024

相关平台

微信小程序

复现仓库

https://github.com/Wyatex/taro-monorepo-bug.git
小程序基础库: -
使用框架: Vue 3

复现步骤

将应用和别的库放在一个monorepo项目里面,库或者应用写下ts的declare语句

期望结果

期望能正常编译

实际结果

编译失败,报错:

✖ Errors: 

ModuleParseError: Module parse failed: Unexpected token (5:8)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| }
|
> declare global {
|   var testObj: Record<string, string>
| }

环境信息

👽 Taro v3.6.18


  Taro CLI 3.6.18 environment info:
    System:
      OS: Windows 11 10.0.22631
    Binaries:
      Node: 16.20.0 - D:\Program Files\nodejs\node.EXE
      Yarn: 1.22.19 - D:\Program Files\nodejs\yarn.CMD
      npm: 8.19.4 - D:\Program Files\nodejs\npm.CMD
    npmPackages:
      @tarojs/cli: 3.6.30 => 3.6.30 
      @tarojs/components: 3.6.30 => 3.6.30 
      @tarojs/helper: 3.6.30 => 3.6.30 
      @tarojs/plugin-framework-vue3: 3.6.30 => 3.6.30 
      @tarojs/plugin-platform-alipay: 3.6.30 => 3.6.30 
      @tarojs/plugin-platform-h5: 3.6.30 => 3.6.30
      @tarojs/plugin-platform-jd: 3.6.30 => 3.6.30
      @tarojs/plugin-platform-qq: 3.6.30 => 3.6.30
      @tarojs/plugin-platform-swan: 3.6.30 => 3.6.30
      @tarojs/plugin-platform-tt: 3.6.30 => 3.6.30
      @tarojs/plugin-platform-weapp: 3.6.30 => 3.6.30
      @tarojs/runtime: 3.6.30 => 3.6.30
      @tarojs/shared: 3.6.30 => 3.6.30
      @tarojs/taro: 3.6.30 => 3.6.30
      @tarojs/taro-loader: 3.6.30 => 3.6.30
      @tarojs/webpack5-runner: 3.6.30 => 3.6.30
      babel-preset-taro: 3.6.30 => 3.6.30
      eslint-config-taro: 3.6.30 => 3.6.30


补充信息

根据多次切换版本研究,在taro3.6.24及以下不会报错,3.6.25直到3.6.30都会报这个错

@taro-bot2 taro-bot2 bot added F-vue3 Framework - Vue 3 T-weapp Target - 编译到微信小程序 V-3 Version - 3.x labels May 22, 2024
@eiinu
Copy link
Contributor

eiinu commented May 22, 2024

#15753 (comment)
可参考这个

@Wyatex
Copy link
Author

Wyatex commented May 22, 2024

可以了,加入include就没问题了

      compile: {
        include: [path.resolve(__dirname, "../../lib")],  // 当前应用src目录以外的目录地址
      },

@Wyatex Wyatex closed this as completed May 22, 2024
This was referenced May 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-vue3 Framework - Vue 3 T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Projects
Archived in project
Development

No branches or pull requests

2 participants