electron-vite-react icon indicating copy to clipboard operation
electron-vite-react copied to clipboard

引用ESM模块的依赖包,打包后报错

Open dylan-7 opened this issue 2 years ago • 2 comments

动态引入imagemin包,开发环境正常,打包后程序报错,找不到这个依赖包,如下图 Screenshot 2023-09-21 at 2 35 52 PM

在electron/main/index.ts中代码:

    const imagemin = (await import('imagemin')).default
    const imageminMozjpeg = (await import('imagemin-mozjpeg')).default

这个问题类似于https://github.com/electron-vite/electron-vite-react/issues/98这个问题,但现在已经版本升级了,请告诉我应该怎么解决。

感谢帮助


Reproduction repo 👉 https://github.com/dylan-7/imagemin

dylan-7 avatar Sep 21 '23 06:09 dylan-7

install imageminis error. pls tell me your node version

RSS1102 avatar Sep 25 '23 10:09 RSS1102

imagemin 放到 devDependencies 中试试看,dependencies 中的依赖默认会被识别成 external 模块

image

caoxiemeihao avatar Oct 31 '23 02:10 caoxiemeihao