Failed to bundle in lib modes with preserveModules and noExternal when module has no export name #12012
Closed
7 tasks done
Labels
bug: upstream
Bug in a dependency of Vite
Describe the bug
I'm trying to bundle node scripts under ssr mode. I need to use some dependency that use native node modules so we have to set
preserveModules
to preserve the use of__dirname
. I also need to externalize node builtins and electron builtins. This setup will fail when I try to build when rollup reads a module that have no export name (just barely export function).The log stops at
Where the
setDynamicImportResolutions
is atrollup/src/Chunk.ts
(permalink)I found somewhere in
Chunk.ts
(permalink)Is the assertion here that modules must have an export name wrong? I'm not expert on it, just guessing.
The yallist/iterator.js is as follows:
There's no export name, just bare anonymous function as output.
Sorry I know this seems to be a pure rollup bug, but I cannot reproduce it using rollup. Vite surely add some configuration and plugins into rollup. So I ended up submit this issue here...
The use case of such a method is discussed at cawa-93/vite-electron-builder#903 if anyone wonders.
Note that
build.rollupOptions.output.entryFileNames
is just used to show the current processing files. Removing it will not solve the bug. Removingbuild.rollupOptions.output.preserveModules
will solve the bug but I need__dirname
working so it's a not workaround.Reproduction
https://github.com/Tanimodori/vite-electron-updater-repro
Steps to reproduce
System Info
Used Package Manager
pnpm
Logs
Click to expand!
Validations
The text was updated successfully, but these errors were encountered: