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

Default export missing when using rollupTypes #319

Closed
3 tasks done
cdauth opened this issue Apr 15, 2024 · 0 comments
Closed
3 tasks done

Default export missing when using rollupTypes #319

cdauth opened this issue Apr 15, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@cdauth
Copy link

cdauth commented Apr 15, 2024

Describe the bug

Apologies if I'm misunderstanding something.

I'm trying to use rollupTypes: true to roll up my type declarations. However, the main export is missing from my bundle.

What seems to be happening is that the plugin generates an index.d.ts file that only contains an export * statement for my entry point, so it's not reexporting the default export. The reason seems to be here where it calls hasExportDefault. That checks whether the file contains a node of type SyntaxKind.ExportAssignment (277) or SyntaxKind.ExportDeclaration (278) with the export name default. This seems to work for a statement like export default test;, but my statement export default class Test { } has the node type SyntaxKind.ClassDeclaration (263).

As a workaround, I was able to declare as class Test { } and then exporting it in a separate statement as export default Test;.

Reproduction

https://stackblitz.com/edit/vitejs-vite-hspghz?file=vite.config.js

Steps to reproduce

Run npm run build and inspect the generated bundle in dist/test.d.mts.d.ts.

System Info

System:
    OS: Linux 6.8 Arch Linux
    CPU: (8) x64 Intel(R) Core(TM) i5-10310U CPU @ 1.70GHz
    Memory: 2.89 GB / 23.11 GB
    Container: Yes
    Shell: 5.2.26 - /bin/bash
  Binaries:
    Node: 21.7.2 - /usr/bin/node
    Yarn: 3.6.3 - /usr/bin/yarn
    npm: 10.5.2 - /usr/bin/npm
    pnpm: 8.15.2 - /usr/bin/pnpm
  Browsers:
    Brave Browser: 123.1.64.122
    Chromium: 124.0.6367.49

Validations

@qmhc qmhc added pending Need further confirmation bug Something isn't working and removed pending Need further confirmation labels Apr 15, 2024
@qmhc qmhc closed this as completed in b84c6e2 Apr 15, 2024
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

No branches or pull requests

2 participants