You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Should we switch SWC or Esbuild for the Test Runners? #1042
To my eyes, both seems good with like minimal changes for a 25% performance improvement. I don't think the error messages massive matter. Maybe SWC is better as it's slightly smaller, and we can use the same thing on TS from what I understood from your whataspp?
Let me know if there's a right/wrong decision here pls. And if we go with SWC, I'll get the console.log thing fixed there.
What i think would be worth to explore before going either direction is to see:
Which one would translate well to the typescript repo? That repo has been reworked over time to be close to this one for easier maintenance. That's not necessarily a goal if we go the approach we are exploring (WhatsApp comments) but for Claude it would be easier if it's layered like that.
The exceptions it's using Babel for should be explored if they can be addressed by either tool. Having both tools in this case would not be great as we would have to deal with quircks in both.
The web based test runner needs to be taken into account with this change. It mocks a few things to be able to run in the browser but Claude can likely figure out the commonality with these.
A reason we used Babel is because we tell people to install lts node which they then don't update. Babel was transpiling down to the node version or at least that was the idea when we started. That evolved over time. The question is if this is necessary at all and if core js is needed still or not.
It's not been there for long but node I believe now understands es6 modules and they are baseline widely available now as well. This is the moment to switch to that. Doing these changes serially is suboptimal.
Link what you and them AI think. Feel free to post in this issue tables of pros and cons. Just like the PR, forwarded content would be good to be marked as [NoRag] By AI. Use a GitHub interstitial.
I'm fine in reducing DX slightly for these repos as they may not necessarily be touched by me directly.
Per your conversations with @iHiD, we've moved away from swapping Babel for SWC or esbuild (those drafts are closed), and are now trying Node's built-in test runner with native ES modules instead:
JavaScript:Find the tests in the test file with acorn #1046 finds the tests with acorn instead of loading the TypeScript compiler, and Run the tests with Node's built-in test runner and native ES modules #1047 runs the tests with node --test and native ES modules, with no Jest or Babel. A small preloaded module provides Jest's API (describe, test, xtest, expect, jest.fn, jest.mock), so the track's test files don't change. The median run on our test machine goes from 2.3s to 0.6s. The PR lists every change students would see.
--detectOpenHandles: we tested the async exercises with and without it, including 14 broken solutions and 210 recent student solutions, and saw no difference. Details are in Stop tracking open handles in every run #1044.
Still to try: the TypeScript version runs as CommonJS and is laid out differently from the JavaScript one, so we're now moving it to ES modules with the same files and structure, to keep the two runners as alike as possible. It also still loads the TypeScript compiler to find the tests, which we're removing.
Both are drafts, up so you can see the direction. Nothing needs merging yet.
If anything here looks fundamentally wrong to you (for example, any of the changes a student would see), that would be helpful to know. Otherwise I'll continue iterating and let you know when I think things are ready for you to look at if you want to.
Yes cool. I'll merge 1044 for now, as that was just waiting on data.
Gimme some time to review the rest. I am 100% on making TS effectively extend the JS and thus also the browser one have similar interface. Easier to understand, easier to maintain, and easier to add a feature across all four (both browser and both system runners).
What would help is if every JS idea is tested against TS (and of course still written in TS), so that approving a JS one is effectively also approving a TS one, and not that we do JS changes and find out it doesn't work in TS.
Note: for TS tstsyche is the idea to teach people types fully. I will work this spring on a full track for typescript. Was not able to do that because of the lack-of-speed of node runner + tstsyche. So optimizing this that we can have both on an exercise (maybe run in parallel?) would be aswesome. There should be an example already... somewhre.
@SleeplessByte Thanks. On the type tests: exercism/typescript-test-runner#107 (draft, on top of #106) runs tstyche in the same process as the type check, reusing the files tsc has already parsed. tstyche was loading its own copy of TypeScript and parsing the DOM and Node types twice, which took about 3s on its own. An exercise with both runtime tests and type tests (lasagna) now runs in 2.4s instead of 5.2s, and the type tests add about 0.3s. Running tstyche in parallel saved nothing on the 2-CPU production machines. One change: the type tests now use the exercise's tsconfig, as they do locally, where before they used tstyche's defaults.
#1043 (compile cache) and #1045 (--forceExit) speed up the current Jest setup. #1047 already passes --test-force-exit, so if you're happy with the node --test direction, #1045 isn't needed, and I'll redo #1043's cache on top of #1047. If you'd rather have a quick win first, both can merge now.
Three smaller APIs used by the drafts aren't stable yet:
mock.module (--experimental-test-module-mocks, "Early development"). Only fruit-picker's jest.mock uses it in JavaScript. If we'd rather avoid it, fruit-picker's test could be changed to inject the dependency instead of mocking the module.
module.registerHooks ("Release candidate" since v24.13.1). Both runners use it so that @jest/globals resolves to the runner's Jest API and imports without .js keep working. The first part could be a small real package in the image instead. The second would need the track's test files to import with .js, which is a mechanical change across the exercises.
module.stripTypeScriptTypes ("Release candidate"). Only the TypeScript runner uses it, to find the tests. It can switch to TypeScript's own parser, which is already loaded for the type check.
I'd remove the last one either way. Would you like me to remove the other two as well, including the track changes, so that nothing experimental is left?
Yes. We cannot use experimental because it has calling impact for cli users.
For mock we can continue to use jest.mocks or write our own.
We should rewrite all imports. Typescript wants it too anyway so let's go consistency
We don't want to strip types but transpile so let's keep using TSC.
Removing everything else indeed. This will be the way. Switching to the node runner should be one PR. The big extension rewrite a single commit.
Now another question: we used Babel to transpile new features to the users' node. Why do we no longer need that and can we also drop core-js or is that something we should keep?
The runner will use no experimental Node APIs. jest.mock will be our own, without Node's mock.module and its flag.
The test files and stubs in exercism/javascript and exercism/typescript will import with full extensions (./two-fer.js), in one commit per track, so the runner no longer needs to resolve extensionless imports.
On Babel and core-js: the preset targets node: 'current', which in the runner is the image's Node (24). So Babel only ever converted ES modules to CommonJS for Jest, and transpiled no syntax. core-js only adds built-ins that the image's Node doesn't have yet. On Node 24 that is Error.isError, Math.sumPrecise, the Uint8Array base64 and hex methods, and fixes to structuredClone. Without core-js, a solution using one of those will fail with "is not a function". Students running the tests locally use the track's own Babel setup, so the runner's change doesn't affect them.
We can drop core-js completely, or preload only those few polyfills, which costs almost nothing. Let me know which you would prefer.
@SleeplessByte Yes, Babel's useBuiltIns: 'usage' read each file and added imports for the core-js modules it used. A cheaper way is to preload, on every run, the eleven core-js modules for built-ins Node 24 doesn't have yet, with --import. That doesn't need any parsing. Locally that adds about 20ms to a run. Once the image moves to a newer Node, the list gets shorter.
And yes, this is full ES modules. Node loads the test file and the solution as native ES modules and resolves their imports itself, with nothing converting them first.
One thing needs your decision. Node's syntax detection is marked "Release candidate" in the Node 24 and 26 docs. It is on by default, with no flag or warning, and the JavaScript runner relies on it, so that grep's CommonJS test file and CommonJS solutions keep working. To avoid it, the runner would set "type": "module". Then grep's test file would need to use import, and CommonJS solutions (13 of 11,083 in a week) would fail to load. Let me know which you would prefer.
core-js: the runners load the polyfills for the 15 built-ins missing from Node 24 on every run, without reading the files. That adds about 15ms. TypeScript moves from core-js 3.37 to 3.49, to match JavaScript, so Math.sumPrecise now works there too.
Release candidate APIs: the runners now use module.registerHooks for imports and jest.mock. That replaced the code that rewrote the imports in the files on disk, and the two runners' hooks are nearly identical. Nothing writes to the student's files any more.
All the example solutions give the same results as on main (for JavaScript, with the track's test files from before and after exercism/javascript#2877).
Activity
SleeplessByte commentedon Nov 21, 2026
What i think would be worth to explore before going either direction is to see:
Link what you and them AI think. Feel free to post in this issue tables of pros and cons. Just like the PR, forwarded content would be good to be marked as [NoRag] By AI. Use a GitHub interstitial.
I'm fine in reducing DX slightly for these repos as they may not necessarily be touched by me directly.
exercism-agent commentedon Nov 23, 2026
@SleeplessByte A quick update on where this has got to.
Per your conversations with @iHiD, we've moved away from swapping Babel for SWC or esbuild (those drafts are closed), and are now trying Node's built-in test runner with native ES modules instead:
node --testand native ES modules, with no Jest or Babel. A small preloaded module provides Jest's API (describe,test,xtest,expect,jest.fn,jest.mock), so the track's test files don't change. The median run on our test machine goes from 2.3s to 0.6s. The PR lists every change students would see.--detectOpenHandles: we tested the async exercises with and without it, including 14 broken solutions and 210 recent student solutions, and saw no difference. Details are in Stop tracking open handles in every run #1044.Still to try: the TypeScript version runs as CommonJS and is laid out differently from the JavaScript one, so we're now moving it to ES modules with the same files and structure, to keep the two runners as alike as possible. It also still loads the TypeScript compiler to find the tests, which we're removing.
Both are drafts, up so you can see the direction. Nothing needs merging yet.
If anything here looks fundamentally wrong to you (for example, any of the changes a student would see), that would be helpful to know. Otherwise I'll continue iterating and let you know when I think things are ready for you to look at if you want to.
SleeplessByte commentedon Nov 23, 2026
Yes cool. I'll merge 1044 for now, as that was just waiting on data.
Gimme some time to review the rest. I am 100% on making TS effectively extend the JS and thus also the browser one have similar interface. Easier to understand, easier to maintain, and easier to add a feature across all four (both browser and both system runners).
What would help is if every JS idea is tested against TS (and of course still written in TS), so that approving a JS one is effectively also approving a TS one, and not that we do JS changes and find out it doesn't work in TS.
Note: for TS tstsyche is the idea to teach people types fully. I will work this spring on a full track for typescript. Was not able to do that because of the lack-of-speed of node runner + tstsyche. So optimizing this that we can have both on an exercise (maybe run in parallel?) would be aswesome. There should be an example already... somewhre.
exercism-agent commentedon Nov 24, 2026
@SleeplessByte Thanks. On the type tests: exercism/typescript-test-runner#107 (draft, on top of #106) runs tstyche in the same process as the type check, reusing the files tsc has already parsed. tstyche was loading its own copy of TypeScript and parsing the DOM and Node types twice, which took about 3s on its own. An exercise with both runtime tests and type tests (lasagna) now runs in 2.4s instead of 5.2s, and the type tests add about 0.3s. Running tstyche in parallel saved nothing on the 2-CPU production machines. One change: the type tests now use the exercise's tsconfig, as they do locally, where before they used tstyche's defaults.
Every JS change now has its TS counterpart:
--detectOpenHandles--forceExit--test-force-exit)node --testand ES modulesFrom here, I'll make each change in both runners together.
SleeplessByte commentedon Nov 24, 2026
Okay.
What's the order of reviewing and merging that's optimal?
exercism-agent commentedon Nov 24, 2026
@SleeplessByte This order works best:
TypeScript, in stack order, as each PR builds on the one before:
node --testand ES modules)JavaScript:
node --testand ES modules). Its setup, Jest API and reporter files are the same as TS Bump docker/login-action from 1.13.0 to 1.14.0 #106's, so it's easiest to review the two together.#1043 (compile cache) and #1045 (
--forceExit) speed up the current Jest setup. #1047 already passes--test-force-exit, so if you're happy with thenode --testdirection, #1045 isn't needed, and I'll redo #1043's cache on top of #1047. If you'd rather have a quick win first, both can merge now.SleeplessByte commentedon Nov 24, 2026
Node --test is fine if you can confirm that it's no longer experimental in LTS
exercism-agent commentedon Nov 24, 2026
@SleeplessByte
node --testitself is stable: Node marked the test runner stable in v20.0.0, and in the current LTS (24) the parts the runners rely on have no experimental status. That coverstest/describe, reporters,--test-timeout,--test-force-exit, and--test-isolation, which dropped its--experimental-prefix in v23.6.0. (Source: https://nodejs.org/docs/latest-v24.x/api/test.html and https://nodejs.org/docs/latest-v24.x/api/cli.html.)Three smaller APIs used by the drafts aren't stable yet:
mock.module(--experimental-test-module-mocks, "Early development"). Only fruit-picker'sjest.mockuses it in JavaScript. If we'd rather avoid it, fruit-picker's test could be changed to inject the dependency instead of mocking the module.module.registerHooks("Release candidate" since v24.13.1). Both runners use it so that@jest/globalsresolves to the runner's Jest API and imports without.jskeep working. The first part could be a small real package in the image instead. The second would need the track's test files to import with.js, which is a mechanical change across the exercises.module.stripTypeScriptTypes("Release candidate"). Only the TypeScript runner uses it, to find the tests. It can switch to TypeScript's own parser, which is already loaded for the type check.I'd remove the last one either way. Would you like me to remove the other two as well, including the track changes, so that nothing experimental is left?
SleeplessByte commentedon Nov 24, 2026
Yes. We cannot use experimental because it has calling impact for cli users.
Removing everything else indeed. This will be the way. Switching to the node runner should be one PR. The big extension rewrite a single commit.
Now another question: we used Babel to transpile new features to the users' node. Why do we no longer need that and can we also drop core-js or is that something we should keep?
exercism-agent commentedon Nov 24, 2026
@SleeplessByte Thanks. This is the plan:
jest.mockwill be our own, without Node'smock.moduleand its flag../two-fer.js), in one commit per track, so the runner no longer needs to resolve extensionless imports.On Babel and core-js: the preset targets
node: 'current', which in the runner is the image's Node (24). So Babel only ever converted ES modules to CommonJS for Jest, and transpiled no syntax. core-js only adds built-ins that the image's Node doesn't have yet. On Node 24 that isError.isError,Math.sumPrecise, theUint8Arraybase64 and hex methods, and fixes tostructuredClone. Without core-js, a solution using one of those will fail with "is not a function". Students running the tests locally use the track's own Babel setup, so the runner's change doesn't affect them.We can drop core-js completely, or preload only those few polyfills, which costs almost nothing. Let me know which you would prefer.
SleeplessByte commentedon Nov 24, 2026
Babel was used to find which modules to load. Is there a more efficient way to do that?
And to confirm. This also means we're going full es modules!?
exercism-agent commentedon Nov 24, 2026
@SleeplessByte Yes, Babel's
useBuiltIns: 'usage'read each file and added imports for the core-js modules it used. A cheaper way is to preload, on every run, the eleven core-js modules for built-ins Node 24 doesn't have yet, with--import. That doesn't need any parsing. Locally that adds about 20ms to a run. Once the image moves to a newer Node, the list gets shorter.And yes, this is full ES modules. Node loads the test file and the solution as native ES modules and resolves their imports itself, with nothing converting them first.
exercism-agent commentedon Nov 24, 2026
@SleeplessByte The changes are up:
main(Find the tests in the test file with acorn #1046 is folded into it), ready for review. It uses only Node APIs marked stable, andjest.mockis our own.One thing needs your decision. Node's syntax detection is marked "Release candidate" in the Node 24 and 26 docs. It is on by default, with no flag or warning, and the JavaScript runner relies on it, so that grep's CommonJS test file and CommonJS solutions keep working. To avoid it, the runner would set
"type": "module". Then grep's test file would need to useimport, and CommonJS solutions (13 of 11,083 in a week) would fail to load. Let me know which you would prefer.SleeplessByte commentedon Nov 24, 2026
Release candidate is fine.
Include the Babel load to the prs please.
exercism-agent commentedon Nov 24, 2026
@SleeplessByte Both are in now, in #1047 and exercism/typescript-test-runner#106:
Math.sumPrecisenow works there too.module.registerHooksfor imports andjest.mock. That replaced the code that rewrote the imports in the files on disk, and the two runners' hooks are nearly identical. Nothing writes to the student's files any more.All the example solutions give the same results as on
main(for JavaScript, with the track's test files from before and after exercism/javascript#2877).SleeplessByte commentedon Nov 24, 2026
Great. I will review. In the meanwhile, please Create an extra follow-up pr that keeps the import list up to date: