Failed to bundle with preserveModules: true
and preserveEntrySignatures: 'allow-extension'
when module has no export name
#4905
Labels
Rollup Version
This bug is able to be reproduced in
Operating System (or Browser)
Linux/Windows
Node Version (if applicable)
16.14.2
Link To Reproduction
https://stackblitz.com/edit/rollup-repro-lvtksv?file=package.json
Describe the bug
I'm trying to bundle node scripts with
preserveModules: true
andpreserveEntrySignatures: 'allow-extension'
. I need to use some dependency that use native node modules so we have to setpreserveModules
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.
Downstream issues:
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.Expected Behaviour
The code should be bundled correctly
Actual Behaviour
The text was updated successfully, but these errors were encountered: