unjs / mkdist

Lightweight file-to-file transpiler.
MIT License
367 stars 25 forks source link

extensions are wrongly added with `addRelativeDeclarationExtensions` and vue + setup #249

Open pi0 opened 1 month ago

pi0 commented 1 month ago

(source: reported by @benjamincanac / reproduced on https://github.com/nuxt/ui/tree/847ee4591abee63cc503bf32d62341d16be6ebc5 dist/runtimes/types/index.ts after build)


https://github.com/unjs/mkdist/pull/243 introduced a regression in 1.5.7+ with addRelativeDeclarationExtensions option since it assumes all source file will emit a .vue.d.ts companion while files with script setup are not transpiled (and therefore don't emit this file), they need type import with .vue

I have added snapshot tests to reproduce it: https://github.com/unjs/mkdist/blob/eb495b042e941c0a68800a0ecb226914a7028218/test/index.test.ts#L177

pi0 commented 1 month ago

/cc @danielroe I think you might be the best to check this when had time 🙏🏼

Teages commented 1 month ago

seems #251 wouln't fix this issues well because I skip dts generate for js-only <script> / <script setup> blocks. should I always generate dts for vue files?

I recheck the output, it will only skip dst generate for vue files which don't have script blocks

(but it will fix the regression here, do I still need to consider the case of no<script> / <script setup> blocks?)