alex8088 / electron-vite

Next generation Electron build tooling based on Vite 新一代 Electron 开发构建工具,支持源代码保护
https://electron-vite.org
MIT License
3.56k stars 153 forks source link

使用 @huggingface/transformers 的时候报错 #666

Closed kingback closed 5 days ago

kingback commented 5 days ago

Describe the bug

renderer 里使用 @huggingface/transformers 的时候,会报下面的错误(v1,v2 都试过),单独使用 vite 的项目是没问题的

Failed to resolve entry for package "/Users/xxx/Dev/transformers/node_modules/.vite/deps". The package may have incorrect main/module/exports specified in its package.json.
20:06:07 [vite] Internal server error: Failed to resolve entry for package "/Users/xxx/Dev/transformers/node_modules/.vite/deps". The package may have incorrect main/module/exports specified in its package.json.
  Plugin: vite:asset-import-meta-url
  File: /Users/xxx/Dev/transformers/node_modules/.vite/deps/@huggingface_transformers.js?v=ae240fe6
      at packageEntryFailure (file:///Users/xxx/Dev/transformers/node_modules/vite/dist/node/chunks/dep-b2890f90.js:28725:11)
      at resolvePackageEntry (file:///Users/xxx/Dev/transformers/node_modules/vite/dist/node/chunks/dep-b2890f90.js:28722:5)
      at tryCleanFsResolve (file:///Users/xxx/Dev/transformers/node_modules/vite/dist/node/chunks/dep-b2890f90.js:28381:28)
      at tryFsResolve (file:///Users/xxx/Dev/transformers/node_modules/vite/dist/node/chunks/dep-b2890f90.js:28328:17)
      at TransformContext.transform (file:///Users/xxx/Dev/transformers/node_modules/vite/dist/node/chunks/dep-b2890f90.js:43235:32)
      at Object.transform (file:///Users/xxx/Dev/transformers/node_modules/vite/dist/node/chunks/dep-b2890f90.js:44352:62)
      at async loadAndTransform (file:///Users/xxx/Dev/transformers/node_modules/vite/dist/node/chunks/dep-b2890f90.js:55026:29)
      at async viteTransformMiddleware (file:///Users/xxx/Dev/transformers/node_modules/vite/dist/node/chunks/dep-b2890f90.js:64434:32)

复现步骤

  1. 新建个 electron-vite 仓库
  2. 安装 @huggingface/transformers
  3. 在 renderer 的代码里使用

示例代码

import { RawImage } from '@huggingface/transformers'
RawImage.read()

Electron-Vite Version

2.3.0/1.0.27

Electron Version

27.0.0

Vite Version

4.4.9

Validations

kingback commented 5 days ago

看起来是 vite 的问题,v5 版本修复了

https://github.com/vitejs/vite/issues/14169 https://github.com/vitejs/vite/pull/14626