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 开启依赖预编译功能编译报错 #14002

Closed
814704261 opened this issue Jun 11, 2023 · 2 comments
Closed

webpack5 开启依赖预编译功能编译报错 #14002

814704261 opened this issue Jun 11, 2023 · 2 comments
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x

Comments

@814704261
Copy link

相关平台

微信小程序

小程序基础库: 无关基础库版本
使用框架: React

复现步骤

config/index.js 中将 compiler.prebundle 开启

期望结果

正常编译

实际结果

无法正常编译运行

环境信息

👽 Taro v3.6.7


  Taro CLI 3.6.7 environment info:
    System:
      OS: Windows 10 10.0.19045
    Binaries:
      Node: 16.18.1 - C:\Program Files\nodejs\node.EXE
      Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD  
      npm: 8.19.2 - C:\Program Files\nodejs\npm.CMD   
    npmPackages:
      @tarojs/cli: 3.6.7 => 3.6.7 
      @tarojs/components: 3.6.7 => 3.6.7 
      @tarojs/helper: 3.6.7 => 3.6.7 
      @tarojs/plugin-framework-react: 3.6.7 => 3.6.7  
      @tarojs/plugin-platform-alipay: 3.6.7 => 3.6.7  
      @tarojs/plugin-platform-h5: 3.6.7 => 3.6.7      
      @tarojs/plugin-platform-jd: 3.6.7 => 3.6.7      
      @tarojs/plugin-platform-qq: 3.6.7 => 3.6.7      
      @tarojs/plugin-platform-swan: 3.6.7 => 3.6.7    
      @tarojs/plugin-platform-tt: 3.6.7 => 3.6.7      
      @tarojs/plugin-platform-weapp: 3.6.7 => 3.6.7   
      @tarojs/react: 3.6.7 => 3.6.7 
      @tarojs/rn-runner: 3.6.7 => 3.6.7 
      @tarojs/rn-supporter: 3.6.7 => 3.6.7
      @tarojs/runtime: 3.6.7 => 3.6.7
      @tarojs/runtime-rn: 3.6.7 => 3.6.7
      @tarojs/shared: 3.6.7 => 3.6.7
      @tarojs/taro: 3.6.7 => 3.6.7
      @tarojs/taro-rn: 3.6.7 => 3.6.7
      @tarojs/webpack5-runner: 3.6.7 => 3.6.7
      babel-preset-taro: 3.6.7 => 3.6.7
      eslint-config-taro: 3.6.7 => 3.6.7
      react: ^18.1.0 => 18.2.0
      react-native: ^0.70.1 => 0.70.9

补充信息

X [ERROR] [plugin scanImports] Invalid option from onResolve() callback in plugin "scanImports": "importer"

node_modules/esbuild/lib/main.js:244:12:
  244 │       throw new Error(`Invalid option ${where}: "${key}"`);
      ╵             ^

at checkForInvalidFlags (E:\tmp\myApp\node_modules\esbuild\lib\main.js:244:13)
at callback (E:\tmp\myApp\node_modules\esbuild\lib\main.js:956:17)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at handleRequest (E:\tmp\myApp\node_modules\esbuild\lib\main.js:713:30)

This error came from the "onResolve" callback registered here:

node_modules/esbuild/lib/main.js:855:22:
  855 │         let promise = setup({
      ╵                       ^

at setup (E:\tmp\myApp\node_modules\@tarojs\webpack5-prebundle\src\prebundle\scanImports.ts:112:13)
at handlePlugins (E:\tmp\myApp\node_modules\esbuild\lib\main.js:855:23)
at Object.buildOrServe (E:\tmp\myApp\node_modules\esbuild\lib\main.js:1149:7)
at E:\tmp\myApp\node_modules\esbuild\lib\main.js:2110:17
at new Promise (<anonymous>)
at Object.build (E:\tmp\myApp\node_modules\esbuild\lib\main.js:2109:14)
at Object.build (E:\tmp\myApp\node_modules\esbuild\lib\main.js:1956:51)
at E:\tmp\myApp\node_modules\@tarojs\webpack5-prebundle\src\prebundle\scanImports.ts:51:21
at Generator.next (<anonymous>)

The plugin "scanImports" was triggered by this import

src/pages/mine/index.tsx:3:7:
  3 │ import './index.scss'
    ╵        ~~~~~~~~~~~~~~
@taro-bot2 taro-bot2 bot added F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x labels Jun 11, 2023
@814704261
Copy link
Author

我感觉是因为 esbuild 不能解析 import 'index.scss',需要给esbuild加一个识别scss的插件

@ZakaryCode
Copy link
Contributor

应该在 #13918 中修复了,可以升级到 3.6.8 试试

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
Archived in project
Development

No branches or pull requests

2 participants