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

Force exception to be thrown and be able to catch it on build.catch #17

Open
sashapetrovska opened this issue Jul 21, 2022 · 1 comment

Comments

@sashapetrovska
Copy link

sashapetrovska commented Jul 21, 2022

First off, I'm loving the plugin, really nice job, but there's a problem, my build is always completed successfully even with type errors, I'd like to be able to catch the exception inside of catch so I can exit the build unsuccessfully.

well, no sure what happen, but I'm talking about esbuild-plugin-typecheck.

Edit: Another bug I just found is that is checking for files I didn't even include in the bundle... like it'd a normal cli tsc.

@jgoz
Copy link
Owner

jgoz commented Jul 21, 2022

Hi there, thanks for the kind words.

I'll have to try this again to see if it's possible. Type checking happens in a completely separate worker thread and it's almost completely disconnected from esbuild, other than it starts at the same time.

It might help to think of it like this: when esbuild starts, it runs tsc and forgets about it. It was designed like this to integrate with my livereload plugin and to deliver errors asynchronously, potentially a very long time after esbuild finishes since TypeScript is so much slower.

It might be possible to add an option that runs it in a "blocking" mode, where the build waits for this plugin to finish, but I seem to recall having issues with that when I was first working on this.

Edit: Another bug I just found is that is checking for files I didn't even include in the bundle... like it'd a normal cli tsc.

Yeah, that's by design. This plugin isn't nearly as complicated as fork-ts-checker-webpack-plugin, it basically just looks for the proper tsconfig.json file and infers which build mode to use based on the options and then does something very similar to invoking tsc.

I'm sure it's possible to build up the files array based on esbuild's dependency graph, but that would delay the initial type check until after esbuild finished, so it's a tradeoff. I'm not opposed to it, but I probably won't be working on it in the near future.

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

No branches or pull requests

2 participants