You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
dataToEsm emits a duplicate default export for a default key with includeArbitraryNames #2001
Rollup Version: N/A — dataToEsm is a standalone utility, no bundling involved
Operating System (or Browser): macOS
Node Version: 20+
Link to reproduction (⚠️ read below): self-contained snippet below (pure function, no bundler needed)
Expected Behavior
When dataToEsm is called with includeArbitraryNames: true on data that has a
key named default, it should produce valid JavaScript. Since dataToEsm always
emits a trailing export default {...}, the default key can only be exposed
through that default export object — it must not also be emitted as a named
export.
Actual Behavior
dataToEsm emits export { _arbitrary0 as "default" }in addition to the
trailing export default {...}. Both forms declare the module's default export,
so the generated code is invalid:
A default key falls into the includeArbitraryNames branch and is emitted as export { _x as "default" }. But both the string form export { x as "default" }
and the identifier form export { x as default } create the module's default
export, which conflicts with the export default {...} that dataToEsm always
appends.
This surfaced while working on Vite's CSS-modules named exports
(vitejs/vite#22393): a .default {} class name compiled
for a modern target produces broken output.
A fix (skip a default key from named exports, keeping it object-only) with a
test is ready and will be opened as a PR referencing this issue.
Activity
shellscape commentedon May 29, 2026
Moving issue to a discussion. Everyone has to follow the same rules.