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

Errors being swallowed when rollupTypes: true #322

Closed
3 tasks done
GeordiD opened this issue Apr 20, 2024 · 2 comments
Closed
3 tasks done

Errors being swallowed when rollupTypes: true #322

GeordiD opened this issue Apr 20, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@GeordiD
Copy link

GeordiD commented Apr 20, 2024

Describe the bug

I've noticed that vite-plugin-dts will report type errors in the build logs but not halt the build. This causes a lot of messy errors in our build logs that should be fixed, but because nothing is stopping CI they keep sneaking into master.

The easiest way I can reproduce this is with api-extractor errors by not tagging exports with @public. I made a reproduction repo showing that which is linked.

I have also seen this happen with non api-extractor errors (i.e. didn't have jest-extended types wired into the tsconfig right and it was throwing errors during vite build but not tsc).

Is this expected behavior for this library? I'd really like my build script to not produce errors, and I'd think that any generated errors should blow up the build and force us to fix them. If I've gone to all the trouble of marking that these api-extractor messages should be "errors" then it'd be nice if they could kill the build too.

Maybe I'm missing a option somewhere?

Reproduction

https://github.com/GeordiD/repro-dts-not-throwing-errors

Steps to reproduce

  1. Install node_modules: pnpm i
  2. Run build: pnpm run build
> repro-dts-not-throwing-errors@0.0.0 build /Users/geordi/dev/repros/repro-dts-not-throwing-errors
> tsc && vite build

vite v5.2.0 building for production...
✓ 1 modules transformed.

[vite:dts] Start generate declaration files...
dist/my-lib.js  0.18 kB │ gzip: 0.16 kB
[vite:dts] Start rollup declaration files...
Analysis will use the bundled TypeScript version 5.4.2
Error: dist/main.d.ts:1:1 - (ae-missing-release-tag) "setupCounter" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
[vite:dts] Declaration files built in 456ms.

✓ built in 492ms

System Info

System:
    OS: 14.2.1 (23C71)
    CPU: Apple M1 Pro
    Memory: 32 GB
    Shell: zsh
Binaries:
  Node: v18.16.0
  pnpm: 8.6.9
npmPackages:
  typescript: ^5.2.2
  vite: ^5.2.0,
  vite-plugin-dts: ^3.8.3

Validations

@GeordiD
Copy link
Author

GeordiD commented Apr 20, 2024

Digging into the source code, it looks like the result is being returned here as false when there is an error here...

...but that return value is never used anywhere (here).

I can't figure out how I would stop the build process from inside this function. Very new to rollup/vite plugins 🤔

I'm also not sure the intention is to halt the build process here. Technically the plugin did it's job.

But if I have it configured to log as an error, shouldn't I be able to configure the plugin to stop the build in cases like this?

(🤷 I'm just someone new to open source trying to help out / asking questions)

@qmhc qmhc closed this as completed in 791a1b7 Apr 23, 2024
@qmhc qmhc added the enhancement New feature or request label Apr 23, 2024
@qmhc
Copy link
Owner

qmhc commented Apr 23, 2024

I added a option 'afterRollup', it will be called after each rollupDeclarationFiles applied. Hope this can solve your issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants