Repository navigation
Transform files with esbuild instead of Babel (~28% faster) - #1040
Draft
exercism-agent[bot] wants to merge 1 commit into
Draft
exercism-agent[bot] wants to merge 1 commit into
exercism-agent[bot] wants to merge 1 commit into
Conversation
esbuild loads and converts files much faster than Babel. Babel still handles files that call jest.mock and files esbuild can't compile. Co-authored-by: iHiD <286476+iHiD@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hello 🙂 I'm working with Claude to try and get our tooling faster.
This PR makes this project around 30% faster. I've run it in production to benchmark things in the real world against the most recent few hundred solutions, so I'm confident that it works robustly. However, I've not written the code. I have tried my hardest to get Claude to write sensible messages and comments that explains stuff, but I'd ask for your patience in the fact I'm sending AI code to you. Everything below here is from your friendly neighbourhood LLM...
This is a draft. #1041 is a second draft that does the same job with SWC, so the two can be compared. Only one of them should be merged.
What changed
Jest uses Babel to turn each solution and test file into CommonJS before it runs them. Babel is written in JavaScript. On a test machine, loading its plugins and running them took about 0.6s of a 2.3s run with a warm disk cache, and more with a cold one.
This PR adds
jest.transformer.js, which hands most files to esbuild instead. esbuild does the same conversion. It is written in Go and ships as one native binary, so it starts and converts a file in a few milliseconds. esbuild also adds"use strict"to each file, as Babel does. This keeps code such as an assignment to a getter-only property throwing an error.To keep every test passing or failing exactly as it does today, Babel still handles two kinds of file:
jest.mock(or a related call). Jest needs these calls moved above the imports, and esbuild can't do that. Today onlyfruit-pickerdoes this.If no file in a run falls into either group, Babel never loads.
Against all 169 example solutions, every test passes or fails as before. Some error messages change slightly, because esbuild names imported modules differently. For example,
TypeError: (0 , _twoFer.twoFer) is not a functionbecomesTypeError: (0 , import_two_fer.twoFer) is not a function. Some stack frames also show different names. Thetwo-fer/fail/emptyfixture is updated to match.console.logoutput still appears under the same test as with Babel.The image grows from 434 MB to 704 MB.
Compared with #1041, esbuild is about 0.04s per run faster and doesn't change which test
console.logoutput appears under. SWC adds less to the image (608 MB instead of 704 MB).This has been tested in production, and has reduced the median run from 2.7s to 1.9s.
🤖 Generated with Claude Code