Skip to content

fix: support array inputs and fixed-string entryFileNames #208

Open
EvilFaeton wants to merge 2 commits intosxzz:mainfrom
EvilFaeton:fix/vite-array-dts
Open

fix: support array inputs and fixed-string entryFileNames #208
EvilFaeton wants to merge 2 commits intosxzz:mainfrom
EvilFaeton:fix/vite-array-dts

Conversation

@EvilFaeton
Copy link
Copy Markdown

@EvilFaeton EvilFaeton commented Mar 16, 2026

I'm not super familiar with the rolldown plugin internals, so I used Claude Code to help trace issue back through plugin hooks, understand fake-js architecture, and validate that my fix was correct and backward-compatible (hopefully).

So, I'm checking those boxes:

  • This PR contains AI-generated code, but I have carefully reviewed it myself. Otherwise, my PR may be closed.
  • I understand that my PR is more likely to be rejected or requested for changes if it contains AI-generated code that I do not fully understand.

Description

Hey! I ran into this while migrating monorepo from vite-plugin-dts + @microsoft/api-extractor to rolldown-plugin-dts. After building some packages with Vite 8 in lib mode output .mts files had raw fakejs arrays like [1, () => [...]] instead of actual TypeScript declarations. Downstream packages could not type-check at all.

What was happening

I'm not super familiar with the rolldown plugin internals, so it took some digging. I added debug logging to hooks and traced it down to two possible separate "bugs" (once again, I was fixing problem I've faced, not sure if it's generic and it makes sense to push it as fix) that combine together in Vite 8 lib mode:

Array inputs not handled in buildStart

Vite 8 passes options.input as array (['src/index.ts']) but buildStart only handled object inputs ({ index: 'src/index.ts' }). When input is array, inputAliasMap stayed empty so emitted DTS chunks got name: undefined instead of smth like index.d.

Fixed-string entryFileNames missing .d in output

Vite 8 lib mode provides entryFileNames as function returning fixed string (like 'index.mjs') not a template with [name]. The entryFileNames hook converted .mjs to .mts but never inserted .d, producing index.mts instead of index.d.mts. Then renderChunk did not recognize it as a DTS file and skipped the fake-js reversal.

fix

  • Added else branch in buildStart to populate inputAliasMap for array inputs deriving chunk names from file basenames
  • Added filename_js_to_dts() step in entryFileNames hook — same pattern that fake-js plugin already uses in its chunkFileNames hook

All 201 tests pass (195 existing + 6 new ones covering these cases).

Linked Issues

Additional context

@EvilFaeton EvilFaeton changed the title Fix/vite array dts fix: support array inputs and fixed-string entryFileNames Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant