Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type generation is broken for subfolders (subfolder is imported with .js extension) #308

Closed
madskronborg opened this issue Jul 3, 2024 · 4 comments · Fixed by unjs/mkdist#244
Labels
bug Something isn't working

Comments

@madskronborg
Copy link

madskronborg commented Jul 3, 2024

Reproduction

Stackblitz

Build command: cd ~/projects/vitejs-vite-tu4fsx/my-module/ && npm run dev:build && npm run prepack

Describe the bug

After upgrading from 0.5.5 to 0.8.0 the generated bundle has invalid import paths for types that exist in subfolders.

We have e.g. the following structure in our nuxt module runtime/ folder:

src/
  runtime/
    types/
      index.ts (export * from './components')
      components/
        index.ts (export * from './Alert')
        Alert.ts

Which results in the following build:

dist/
  runtime/
    types/
      index.d.ts (export * from './components.js')
      components/
        index.d.ts (export * from './Alert.js')
        Alert.d.ts
        Alert.js

Where the path ./components.js is invalid. It should be: ./components.
I am also unsure whether components/index.d.ts in the build should export ./Alert.js or Alert.d.ts.

@danielroe danielroe added the bug Something isn't working label Jul 3, 2024
@danielroe
Copy link
Member

I'll fix this, but you should probably do from './components/index' anyway. (And this should probably resolve the issue for now.)

@madskronborg
Copy link
Author

I'll fix this, but you should probably do from './components/index' anyway. (And this should probably resolve the issue for now.)

Thank you for the quick reply and the great work on nuxt! :)

I hadn't thought about referencing the index file directly - I tested it and it does indeed fix the type referencing.

Appreciate the help 👍

@BobbieGoede
Copy link
Member

I think fixing this issue or at least logging some warnings when importing from a folder index (without filename) will probably save us a lot of time debugging type issues in the future 😅

Not sure where to start to work on a fix 😥

@danielroe
Copy link
Member

Was just looking at this. I think maybe issue is upstream in mkdist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants