-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Generate code coverage instrumentation #184
Comments
I agree that this could be cool, but it's outside the intended scope of esbuild. And while esbuild is intending to add support for plugins in the future (#111), a plugin for this likely wouldn't have much of a speed advantage over other approaches since it'd have to re-parse the source code. So you'll have to stick to Babel for this unfortunately. I could see maybe adding a code coverage transformation to esbuild if it's something super simple (e.g. "call this function with the line number before every statement"). But I'm guessing it's something more complicated, pretty custom to Istanbul, and not that useful for other code coverage tools, which seems more appropriate for a plugin. |
Thanks for your response. I do appreciate that you're looking to keep the project scope very focused. |
I'm going to close this since I consider it out of scope for esbuild. |
…y are executed - needed for error handling
… the end of a chunk
…y are executed - needed for error handling
why? |
If you re-parse the source code, then that's going to be your bottleneck. It means that your build will be nearly as slow as a JavaScript-based bundler (assuming you use a JavaScript-based parser to implement this) since that's what a JavaScript-based bundler would be doing. |
afaiu, reparsing would be needed anyway to add coverage instrumentation. So, wouldn't instrumenting with an esbuild plugin be faster than a babel based plugin? edit: read about esbuild plugins (had a misunderstanding how they worked). I see that the file would be needed to be reparsed to add instrumentation. esbuild would only work on the module dependencies part. |
There is no need to instrument the source code if using native V8 coverage data in 2024, here is the tool monocart-coverage-reports |
I'm working on a new test runner where I am evaluating
esbuild
to replace babel.I can replace most things, but one final major part I need babel for is generating code coverage instrumentation for https://istanbul.js.org/ using https://github.com/istanbuljs/babel-plugin-istanbul.
Do you think that something like this could be added to
esbuild
?The text was updated successfully, but these errors were encountered: