fix(typescript): no loader required under Bun - #5699
Open
mirao wants to merge 1 commit into
Open
Conversation
Bun transpiles TypeScript natively, so `module.register()` is a no-op stub and a registered tsx/ts-node loader never runs. checkTypeScriptLoader() only string-matched the `require` array against a hardcoded list of Node loaders, so `require: ['tsx/esm']` was mandatory under Bun purely to satisfy that match, forcing tsx into devDependencies to do nothing on every run. Return true early when process.versions.bun is set. This is deliberately Bun-specific rather than "skip the check when the runtime handles TypeScript": Node cannot replace tsx here, as its native type stripping rejects enums and does not resolve extensionless relative imports. Adds unit tests for loaderCheck.js, which had no coverage, pinning both the new Bun branch and the existing Node behaviour. Fixes codeceptjs#5697 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
kobenguyent
approved these changes
Sep 8, 2026
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.
Fixes #5697
Problem
require: ['tsx/esm']is mandatory even when running under Bun, which transpiles TypeScript natively. Without it the run aborts withprocess.exit(1)and the "TypeScript Test Files Detected but No Loader Configured" banner — although the tests run perfectly fine once the check is bypassed.checkTypeScriptLoader()only string-matches therequirearray against a hardcoded list of Node loaders; there is no check of whether the runtime already handles TypeScript. So under Bun therequireentry exists purely to satisfy that string match, andtsxsits indevDependenciesand is imported on every run only to do nothing.Bun's
module.register()is a no-op stub, so tsx'sresolve/loadhooks are never invoked. Verified with a hooks module that logs on every call:bun --bunproduces no hook line at all (and the enum evaluates fine, Bun having transpiled it itself), whilenode --experimental-strip-typesdoes fire the hooks.Fix
Return
trueearly fromcheckTypeScriptLoader()whenprocess.versions.bunis set.This is deliberately Bun-specific and not "skip the check whenever the runtime can do TypeScript". Node cannot replace
tsxhere: its native type stripping rejects enums (ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX) and does not resolve extensionless relative imports.Verification
Ran the minimal reproduction from the issue against this branch — Bun 1.4.2, no
requireentry,tsxnot installed:✔ plain TS scenario with an enum—OK | 1 passedThe Node row is the negative control: the fix is Bun-gated, so Node still demands a real loader — which it must, since native type stripping rejects the
enumin that very repro file.Also confirmed on a real 14-suite Playwright project (~1900 tests): removing the
requireline and deletingtsxfromnode_modulesentirely, a full browser run passed unchanged — page objects, enums and extensionless relative imports included.Tests
lib/utils/loaderCheck.jshad no unit coverage. Addedtest/unit/utils/loaderCheck_test.js, which stubsprocess.versions.bun(mutable under both runtimes) and restores it inafterEach, pinning both the new Bun branch and the pre-existing Node behaviour so the loader list cannot regress silently.mocha test/unit --recursive): 775 passing, 11 pending, 0 failing🤖 Generated with Claude Code