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

webpack5 编译报 [ERROR] [plugin scanImports] Can't resolve 错,在采用文件后缀拆分的方式时 #14123

Closed
TimCN opened this issue Jul 6, 2023 · 0 comments · Fixed by #14277
Labels
A-PreBundle Area - 依赖预编译 E-medium Helper Wanted - Medium F-react Framework - React T-h5 Target - 编译到 H5 V-3 Version - 3.x
Milestone

Comments

@TimCN
Copy link

TimCN commented Jul 6, 2023

相关平台

H5

复现仓库

https://github.com/TimCN/plugin-scan-import-error.git
浏览器版本: 最新Chrome
使用框架: React

复现步骤

  1. taro init myApp
  2. 依次选择:React 》TypeScript 》Sass 》Webpack5 》npm 》 Github(最新)》默认模版
  3. 添加 src/pages/index/utils/index.h5.tssrc/pages/index/utils/index.weapp.ts文件,并导出一些方法,例如:
export const add = (a,b) => {
 return `h5: ${a b}`
}
  1. src/pages/index/index.tsx 中导入并使用该方法 import { add } from './utils'
  2. npm run dev:h5

期望结果

控制台不报错

实际结果

控制台报[ERROR] [plugin scanImports] Can't resolve 错

环境信息

  Taro CLI 3.6.8 environment info:
    System:
      OS: macOS 10.15.7
      Shell: 5.7.1 - /bin/zsh
    Binaries:
      Node: 14.21.3 - ~/.nvm/versions/node/v14.21.3/bin/node
      Yarn: 1.22.19 - ~/.nvm/versions/node/v14.21.3/bin/yarn
      npm: 6.14.18 - ~/.nvm/versions/node/v14.21.3/bin/npm
    npmPackages:
      @tarojs/cli: 3.6.8 => 3.6.8 
      @tarojs/components: 3.6.8 => 3.6.8 
      @tarojs/helper: 3.6.8 => 3.6.8 
      @tarojs/plugin-framework-react: 3.6.8 => 3.6.8 
      @tarojs/plugin-platform-alipay: 3.6.8 => 3.6.8 
      @tarojs/plugin-platform-h5: 3.6.8 => 3.6.8 
      @tarojs/plugin-platform-jd: 3.6.8 => 3.6.8 
      @tarojs/plugin-platform-qq: 3.6.8 => 3.6.8 
      @tarojs/plugin-platform-swan: 3.6.8 => 3.6.8 
      @tarojs/plugin-platform-tt: 3.6.8 => 3.6.8 
      @tarojs/plugin-platform-weapp: 3.6.8 => 3.6.8 
      @tarojs/react: 3.6.8 => 3.6.8 
      @tarojs/runtime: 3.6.8 => 3.6.8 
      @tarojs/shared: 3.6.8 => 3.6.8 
      @tarojs/taro: 3.6.8 => 3.6.8 
      @tarojs/taro-loader: 3.6.8 => 3.6.8 
      @tarojs/webpack5-runner: 3.6.8 => 3.6.8 
      babel-preset-taro: 3.6.8 => 3.6.8 
      eslint-config-taro: 3.6.8 => 3.6.8 
      react: ^18.0.0 => 18.2.0 

@taro-bot2 taro-bot2 bot added F-react Framework - React T-h5 Target - 编译到 H5 V-3 Version - 3.x labels Jul 6, 2023
@ZakaryCode ZakaryCode added A-PreBundle Area - 依赖预编译 E-medium Helper Wanted - Medium labels Jul 10, 2023
@Chen-jj Chen-jj added this to the 3.6.12 milestone Jul 31, 2023
ZakaryCode pushed a commit that referenced this issue Aug 11, 2023
* fix(prebundle): 修复多端文件解析在开启 prebundle 功能时报错的问题,fix #14123

* chore(cli): 更新默认模板的 TS 版本

* fix(prebundle): 修复 es 语法错误
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-PreBundle Area - 依赖预编译 E-medium Helper Wanted - Medium F-react Framework - React T-h5 Target - 编译到 H5 V-3 Version - 3.x
Projects
Archived in project
3 participants