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

在 pnpm workspace 的情况下, 包内引入文件的时候不应当使用静态的包名, 而应当尝试绝对路径 #15089

Open
SuperSaiyr opened this issue Jan 9, 2024 · 3 comments
Assignees
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x

Comments

@SuperSaiyr
Copy link

相关平台

微信小程序

**小程序基础库: ***
使用框架: React

复现步骤

以@tarojs__plugin-framework-react@3.6.16为例

dist/api-loader.js 中对应 runtime.js 的引用是这样

// pnpm workspace 可以存在多个不同或者相同版本不同hash的包, 这样写不能保证索引和运行的是同一个
- import { ...some_module } from '@tarojs/plugin-framework-react/dist/runtime'
  import { ...some_module } from '${path.resolve(__dirname, '/runtime')}'

可能会导致诸如 react 注入失败等问题

在 @tarojs__plugin-inject / @tarojs__plugin-framework-react 等相似使用的包都有这样的情况;

期望结果

正确的引入对应的包内容

实际结果

错误的引入包内容

环境信息

 Taro CLI 2.2.9 environment info:
    System:
      OS: macOS 14.1.2
      Shell: 5.9 - /bin/zsh
    Binaries:
      Node: 14.21.3 - ~/.nvm/versions/node/v14.21.3/bin/node
      Yarn: 1.22.17 - /opt/homebrew/bin/yarn
      npm: 6.14.18 - ~/.nvm/versions/node/v14.21.3/bin/npm
    npmPackages:
      @tarojs/cli: 2.2.9 => 2.2.9 
      @tarojs/components: 2.2.9 => 2.2.9 
      @tarojs/components-qa: 2.2.9 => 2.2.9 
      @tarojs/mini-runner: 2.2.19 => 2.2.19 
      @tarojs/plugin-less: 2.2.9 => 2.2.9 
      @tarojs/plugin-stylus: 2.2.9 => 2.2.9 
      @tarojs/plugin-terser: ^2.2.10 => 2.2.10 
      @tarojs/plugin-uglify: 2.2.9 => 2.2.9 
      @tarojs/router: 2.2.9 => 2.2.9 
      @tarojs/taro: 2.2.9 => 2.2.9 
      @tarojs/taro-alipay: 2.2.9 => 2.2.9 
      @tarojs/taro-h5: 2.2.9 => 2.2.9 
      @tarojs/taro-qq: 2.2.9 => 2.2.9 
      @tarojs/taro-quickapp: 2.2.9 => 2.2.9 
      @tarojs/taro-rn: 2.2.9 => 2.2.9 
      @tarojs/taro-swan: 2.2.9 => 2.2.9 
      @tarojs/taro-tt: 2.2.9 => 2.2.9 
      @tarojs/taro-weapp: 2.2.9 => 2.2.9 
      @tarojs/webpack-runner: 2.2.9 => 2.2.9 
      eslint-config-taro: 2.2.9 => 2.2.9 
      eslint-plugin-taro: 2.2.9 => 2.2.9 

任何一个版本都能复现
@taro-bot2 taro-bot2 bot added F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x labels Jan 9, 2024
@SuperSaiyr
Copy link
Author

#11097@minzojian 遇到的就是这个问题

@SuperSaiyr
Copy link
Author

@tarojs__plugin-platform-weapp@4.0.0-canary.5

这个包也有这个问题

@SuperSaiyr
Copy link
Author

SuperSaiyr commented Feb 2, 2024

复现demo

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
Status: Todo
Development

No branches or pull requests

2 participants