SyncValsverifier → artifact → classifier → verdict
SyncVals · Trajectory

evanw-esbuild-4417

codex gpt-5.5 ✓ resolved GOOD_SUCCESS ↑ View task
Solved from the instruction alone, tests/ and solution/ were withheld from the agent's workspace and restored only for grading.
Reward = tests/test.sh exit code (0 → resolved); the classification below is post-hoc and cannot change it.
Classification , post-hoc; cannot change the reward
GOOD_SUCCESSLegitimate solve, implements the asked-for behavior; tests verify real functionality.
SubtypeLegitimate Solution
EvidenceAll 6 tests passed: test_async_generator_lowering_matches_native PASSED, test_bundled_output_uses_lowered_async_generator_helpers PASSED, test_case_roster_actually_ran PASSED, test_output_is_json_trace PASSED, test_async_generator_compatibility_targets_still_require_lowering PASSED, test_no_hardcoded_hidden_literals PASSED. Result: reward=1.0 (verified pass). Test suite completed in 3.19s with no errors or warnings.
Root causeThe agent successfully implemented fixes to the async generator runtime helpers in esbuild's Go transpiler to properly sequence concurrent iterator method calls (next, throw, return) using a promise-valued queue while preserving native JavaScript semantics for delegated generators, try/finally cleanup, and synchronous side-effect ordering.
RecommendationN/A - task is fine
Trajectory
Tool-by-tool agent trajectory
46 tool calls · 2 tool types · 73 steps
<permissions instructions> Filesystem sandboxing defines which files can be read or written. `sandbox_mode` is `danger-full-access`: No filesystem sandboxing - all commands are permitted. Network access is enabled. Approval policy is currently never. Do not provide the `sandbox_permissions` for any reason, commands will be rejected. </permissions instructions><apps_instructions> ## Apps (Connectors) Apps (Connectors) can be explicitly triggered in user messages in the format `[$app-name](app://{connector_id})`. Apps can also be implicitly triggered as long as the context suggests usage of available apps. An app is equivalent to a set of MCP tools within the `codex_apps` MCP. An installed app's MCP tools are either provided to you already, or can be lazy-loaded through the `tool_search` tool. If `tool_search` is available, the apps that are searchable by `tools_search` will be listed by it. Do not additionally call list_mcp_resources or list_mcp_resource_templates for apps. </apps_instructions><skills_instructions> ## Skills A skill is a set of instructions provided through a `SKILL.md` source. Below is the list of skills that can be used. Each entry includes a name, description, and source locator. `file` locators are on the host filesystem, `environment resource` locators are owned by an execution environment, `orchestrator resource` locators are opaque non-filesystem resources, and `custom resource` locators use their provider's access mechanism. ### Available skills - imagegen: Generate or edit raster images when the task benefits from AI-created bitmap visuals such as photos, illustrations, textures, sprites, mockups, or transparent-background cutouts. Use when Codex should create a brand-new image, transform an existing image, or derive visual variants from references, and the output should be a bitmap asset rather than repo-native code or vector. Do not use when the task is better handled by editing existing SVG/vector/code-native assets, extending an established icon or logo system, or building the visual directly in HTML/CSS/canvas. (file: /tmp/codex-home/skills/.system/imagegen/SKILL.md) - openai-docs: Use when the user asks how to build with OpenAI products or APIs, asks about Codex itself or choosing Codex surfaces, needs up-to-date official documentation with citations, help choosing the latest model for a use case, or model upgrade and prompt-upgrade guidance; use OpenAI docs MCP tools for non-Codex docs questions, use the Codex manual helper first for broad Codex self-knowledge, and restrict fallback browsing to official OpenAI domains. (file: /tmp/codex-home/skills/.system/openai-docs/SKILL.md) - plugin-creator: Create and scaffold plugin directories for Codex with a required `.codex-plugin/plugin.json`, optional plugin folders/files, valid manifest defaults, and personal-marketplace entries by default. Use when Codex needs to create a new personal plugin, add optional plugin structure, generate or update marketplace entries for plugin ordering and availability metadata, or update an existing local plugin during development with the CLI-driven cachebuster and reinstall flow. (file: /tmp/codex-home/skills/.system/plugin-creator/SKILL.md) - skill-creator: Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that extends Codex's capabilities with specialized knowledge, workflows, or tool integrations. (file: /tmp/codex-home/skills/.system/skill-creator/SKILL.md) - skill-installer: Install Codex skills into $CODEX_HOME/skills from a curated list or a [code-host] repo path. Use when a user asks to list installable skills, install a curated skill, or install a skill from another repo (including private repos). (file: /tmp/codex-home/skills/.system/skill-installer/SKILL.md) ### How to use skills - Discovery: The list above is the skills available in this session (name + description + source locator). `file` entries live on the host filesystem, `environment resource` entries are owned by their execution environment, `orchestrator resource` entries must be accessed through `skills.list` and `skills.read`, and `custom resource` entries use their provider's access mechanism. - Trigger rules: If the user names a skill (with `$SkillName` or plain text) OR the task clearly matches a skill's description shown above, you must use that skill for that turn. Multiple mentions mean use them all. Do not carry skills across turns unless re-mentioned. - Missing/blocked: If a named skill isn't in the list or its source can't be read, say so briefly and continue with the best fallback. - How to use a skill (progressive disclosure): 1) After deciding to use a skill, the main agent must read its `SKILL.md` completely before taking task actions. For a `file` entry, open the listed path. For an `environment resource`, use the filesystem of the owning environment. For an `orchestrator resource`, call `skills.list` with `{"authority":{"kind":"orchestrator"}}`, select the matching package, and pass its `main_resource` to `skills.read`. If a read is truncated or paginated, continue until EOF. 2) When `SKILL.md` references another resource, use the same access mechanism. Resolve relative paths against a filesystem-backed skill directory. For orchestrator skills, pass the exact referenced resource identifier with the same authority and package to `skills.read`; do not treat `skill://` identifiers as filesystem paths. 3) If `SKILL.md` points to extra folders such as `references/`, use its routing instructions to identify the resources required for the task. The main agent must read each required instruction or reference file itself before acting on it. Do not delegate reading, summarizing, or interpreting skill instructions to a subagent. Subagents may still perform task work when the selected skill allows it. 4) For filesystem-backed skills, prefer running or patching provided scripts instead of retyping large code blocks. For orchestrator skills, use `skills.read` and the available tools; do not invent a local path. 5) Reuse provided assets or templates through the same source access mechanism instead of recreating them. - Coordination and sequencing: - If multiple skills apply, choose the minimal set that covers the request and state the order you'll use them. - Announce which skill(s) you're using and why (one short line). If you skip an obvious skill, say why. - Context hygiene: - Progressive disclosure applies to selecting relevant files, not partially reading a selected instruction file. Do not load unrelated references, scripts, or assets. - Avoid deep reference-chasing: prefer opening only files directly linked from `SKILL.md` unless you're blocked. - When variants exist (frameworks, providers, domains), pick only the relevant reference file(s) and note that choice. - Safety and fallback: If a skill can't be applied cleanly (missing files, unclear instructions), state the issue, pick the next-best approach, and continue. </skills_instructions>
<environment_context> <cwd>/app</cwd> <shell>bash</shell> <current_date>2026-06-21</current_date> <timezone>Etc/UTC</timezone> <filesystem><workspace_roots><root>/app</root></workspace_roots><permission_profile type="disabled"><file_system type="unrestricted" /></permission_profile></filesystem> </environment_context>
The project in /app is a JavaScript bundler written in Go. When it lowers async generator syntax for older targets, the transformed program should preserve native async generator behavior. Calling next, throw, or return on an async generator before earlier iterator method promises have settled must behave like native JavaScript. The first call should start synchronously up to the first await or yield point, later calls must be sequenced correctly, delegated async iteration must not skip values, and a return value supplied to a queued call must be delivered to the right suspended yield expression. Fix the lowering so transformed output matches native Node behavior for concurrent iterator method calls, delegated async generators, for-await loops, return-through-yield flows, and synchronous side-effect ordering. Queued return() calls must still run cleanup code from finally blocks and deliver any value yielded by that cleanup. Queued throw() calls must enter matching catch blocks at the same suspended point as native async generators and preserve the yielded recovery value. The observable contract includes yielded values, done flags, propagated errors, values sent back into suspended yield expressions, and the order of synchronous side effects that occur before and after awaited work. The runtime helpers are in /app/internal/runtime/runtime.go. Coordinate __asyncGenerator with delegated iteration through __yieldStar so queued return, throw, and next calls preserve native finally-yield timing. Keep existing CLI and API behavior unchanged. The fix must handle dozens of concurrent-call patterns, including delegated generators whose inner iterator is waiting on a promise inside try/finally or catch code. A queue that only uses an array plus a running flag is not enough if it lets delegated return() or throw() skip the same promise-completion ordering as native async generators. Preserve the __yieldStar __await handoff protocol: when a delegated iterator result is pending, the outer async generator must resume through the same ordered promise chain instead of resolving the delegated call outside that chain. Use a promise-valued queue rather than a detached array of pending calls when sequencing iterator methods. Each next, throw, and return call should chain its resume work from the previous call's promise so native microtask order is preserved. When no earlier iterator method is still pending, the first resume callback must start immediately and run synchronously until the generator reaches its next await or yield point. Do not add a microtask hop before that first resume; doing so changes side effects that occur before the first await. The scheduling is intentionally asymmetric. A queued next or throw operation that can resume the generator must not be delayed behind an extra Promise.resolve().then hop just because the implementation uses a promise-valued queue. A queued return operation, however, must still wait for the pending yield or delegated-yield handoff to settle before running return cleanup, so the first next result is observed before finally-side effects and cleanup yields from the queued return. A useful minimal check is an outer async generator that yield* delegates to an inner async generator whose try block yields an awaited value and whose finally block records a side effect before yielding a cleanup value. If a caller issues next() and then return("done") before awaiting either promise, the finally side effect is not visible when the first next() promise resolves; the cleanup yield belongs to the queued return() continuation. Seeing the side effect before the first result is observed means delegated cleanup is running too early. The same ordering must hold when more than one resume is queued before a return. For example, if a caller starts two next() calls, then a return("done") call, and then another next("after") call before awaiting any of those promises, the second next() result must settle before return cleanup runs. Cleanup side effects and cleanup yields belong to the queued return() continuation, and the later next("after") observes the generator state that native JavaScript would leave after that return path. Acceptance criteria: - `go build ./cmd/...` succeeds. - Bundled output for es2017 and es6 uses the async generator runtime helpers instead of native async generator or for-await syntax. - Lowered output produces the same JSON trace as native Node.js for concurrent next, throw, and return calls, including delegated generators with awaited yields, try/finally cleanup yields, try/catch recovery yields, and values sent back into suspended yield expressions. - The compatibility table must continue to require async-generator lowering for es2017 and es6 targets. Do not make compatibility-table changes that avoid lowering instead of fixing the runtime helper. Preserve the existing runtime helper exports, including __forAwait, so lowered for-await loops continue to link and execute through the runtime helpers.
I’ll inspect the bundler’s async generator lowering and runtime helpers first, then reproduce the behavior with targeted tests before patching the runtime.
shell
rg -n "asyncGenerator|yieldStar|forAwait|__asyncGenerator|__yieldStar|__forAwait" internal cmd scripts tests
output
Chunk ID: bd93e9
Wall time: 0.0000 seconds
Process exited with code 2
Original token count: 2311
Output:
rg: scripts: No such file or directory (os error 2)
rg: tests: No such file or directory (os error 2)
internal/bundler_tests/snapshots/snapshots_lower.txt:24:    for (var iter = __forAwait(b), more, temp, error; more = !(temp = await iter.next()).done; more = !1) {
internal/bundler_tests/snapshots/snapshots_lower.txt:1180:  return __asyncGenerator(this, null, function* () {
internal/bundler_tests/snapshots/snapshots_lower.txt:1185:      yield* __yieldStar(x);
internal/bundler_tests/snapshots/snapshots_lower.txt:1188:        for (var iter = __forAwait(y), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
internal/bundler_tests/snapshots/snapshots_lower.txt:1202:        for (var iter2 = __forAwait(y), more2, temp2, error2; more2 = !(temp2 = yield new __await(iter2.next())).done; more2 = false) {
internal/bundler_tests/snapshots/snapshots_lower.txt:1233:  return __asyncGenerator(this, null, function* () {
internal/bundler_tests/snapshots/snapshots_lower.txt:1238:      yield* __yieldStar(x);
internal/bundler_tests/snapshots/snapshots_lower.txt:1241:        for (var iter = __forAwait(y), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
internal/bundler_tests/snapshots/snapshots_lower.txt:1255:        for (var iter2 = __forAwait(y), more2, temp2, error2; more2 = !(temp2 = yield new __await(iter2.next())).done; more2 = false) {
internal/bundler_tests/snapshots/snapshots_lower.txt:1286:  return __asyncGenerator(this, null, function* () {
internal/bundler_tests/snapshots/snapshots_lower.txt:1291:      yield* __yieldStar(x);
internal/bundler_tests/snapshots/snapshots_lower.txt:1294:        for (var iter = __forAwait(y), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
internal/bundler_tests/snapshots/snapshots_lower.txt:1308:        for (var iter2 = __forAwait(y), more2, temp2, error2; more2 = !(temp2 = yield new __await(iter2.next())).done; more2 = false) {
internal/bundler_tests/snapshots/snapshots_lower.txt:1340:    return __asyncGenerator(this, null, function* () {
internal/bundler_tests/snapshots/snapshots_lower.txt:1345:        yield* __yieldStar(x);
internal/bundler_tests/snapshots/snapshots_lower.txt:1348:          for (var iter = __forAwait(y), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
internal/bundler_tests/snapshots/snapshots_lower.txt:1362:          for (var iter2 = __forAwait(y), more2, temp2, error2; more2 = !(temp2 = yield new __await(iter2.next())).done; more2 = false) {
internal/bundler_tests/snapshots/snapshots_lower.txt:1395:    return __asyncGenerator(this, null, function* () {
internal/bundler_tests/snapshots/snapshots_lower.txt:1400:        yield* __yieldStar(x);
internal/bundler_tests/snapshots/snapshots_lower.txt:1403:          for (var iter = __forAwait(y), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
internal/bundler_tests/snapshots/snapshots_lower.txt:1417:          for (var iter2 = __forAwait(y), more2, temp2, error2; more2 = !(temp2 = yield new __await(iter2.next())).done; more2 = false) {
internal/bundler_tests/snapshots/snapshots_lower.txt:1460:  return __asyncGenerator(this, null, function* () {
internal/bundler_tests/snapshots/snapshots_lower.txt:1465:      yield* __yieldStar(x);
internal/bundler_tests/snapshots/snapshots_lower.txt:1468:        for (var iter = __forAwait(y), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
internal/bundler_tests/snapshots/snapshots_lower.txt:1482:        for (var iter2 = __forAwait(y), more2, temp2, error2; more2 = !(temp2 = yield new __await(iter2.next())).done; more2 = false) {
internal/bundler_tests/snapshots/snapshots_lower.txt:1513:  return __asyncGenerator(this, null, function* () {
internal/bundler_tests/snapshots/snapshots_lower.txt:1518:      yield* __yieldStar(x);
internal/bundler_tests/snapshots/snapshots_lower.txt:1521:        for (var iter = __forAwait(y), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
internal/bundler_tests/snapshots/snapshots_lower.txt:1535:        for (var iter2 = __forAwait(y), more2, temp2, error2; more2 = !(temp2 = yield new __await(iter2.next())).done; more2 = false) {
internal/bundler_tests/snapshots/snapshots_lower.txt:1566:  return __asyncGenerator(this, null, function* () {
internal/bundler_tests/snapshots/snapshots_lower.txt:1571:      yield* __yieldStar(x);
internal/bundler_tests/snapshots/snapshots_lower.txt:1574:        for (var iter = __forAwait(y), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
internal/bundler_tests/snapshots/snapshots_lower.txt:1588:        for (var iter2 = __forAwait(y), more2, temp2, error2; more2 = !(temp2 = yield new __await(iter2.next())).done; more2 = false) {
internal/bundler_tests/snapshots/snapshots_lower.txt:1620:    return __asyncGenerator(this, null, function* () {
internal/bundler_tests/snapshots/snapshots_lower.txt:1625:        yield* __yieldStar(x);
internal/bundler_tests/snapshots/snapshots_lower.txt:1628:          for (var iter = __forAwait(y), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
internal/bundler_tests/snapshots/snapshots_lower.txt:1642:          for (var iter2 = __forAwait(y), more2, temp2, error2; more2 = !(temp2 = yield new __await(iter2.next())).done; more2 = false) {
internal/bundler_tests/snapshots/snapshots_lower.txt:1675:    return __asyncGenerator(this, null, function* () {
internal/bundler_tests/snapshots/snapshots_lower.txt:1680:        yield* __yieldStar(x);
internal/bundler_tests/snapshots/snapshots_lower.txt:1683:          for (var iter = __forAwait(y), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
internal/bundler_tests/snapshots/snapshots_lower.txt:1697:          for (var iter2 = __forAwait(y), more2, temp2, error2; more2 = !(temp2 = yield new __await(iter2.next())).done; more2 = false) {
internal/bundler_tests/snapshots/snapshots_lower.txt:2077:      for (var iter = __forAwait(y), more, temp, error; more = !(temp = yield iter.next()).done; more = false) {
internal/bundler_tests/snapshots/snapshots_lower.txt:2094:      for (var iter = __forAwait(y), more, temp, error; more = !(temp = yield iter.next()).done; more = false) {
internal/bundler_tests/snapshots/snapshots_lower.txt:2111:      for (var iter = __forAwait(y), more, temp, error; more = !(temp = yield iter.next()).done; more = false) {
internal/bundler_tests/snapshots/snapshots_lower.txt:2128:      for (var iter = __forAwait(y), more, temp, error; more = !(temp = yield iter.next()).done; more = false) {
internal/bundler_tests/snapshots/snapshots_lower.txt:2145:      label: for (var iter = __forAwait(y), more, temp, error; more = !(temp = yield iter.next()).done; more = false) {
internal/bundler_tests/snapshots/snapshots_lower.txt:2162:      label: for (var iter = __forAwait(y), more, temp, error; more = !(temp = yield iter.next()).done; more = false) {
internal/bundler_tests/snapshots/snapshots_lower.txt:2185:      for (var iter = __forAwait(y), more, temp, error; more = !(temp = await iter.next()).done; more = false) {
internal/bundler_tests/snapshots/snapshots_lower.txt:2202:      for (var iter = __forAwait(y), more, temp, error; more = !(temp = await iter.next()).done; more = false) {
internal/bundler_tests/snapshots/snapshots_lower.txt:2219:      for (var iter = __forAwait(y), more, temp, error; more = !(temp = await iter.next()).done; more = false) {
internal/bundler_tests/snapshots/snapshots_lower.txt:2236:      for (var iter = __forAwait(y), more, temp, error; more = !(temp = await iter.next()).done; more = false) {
internal/bundler_tests/snapshots/snapshots_lower.txt:2253:      label: for (var iter = __forAwait(y), more, temp, error; more = !(temp = await iter.next()).done; more = false) {
internal/bundler_tests/snapshots/snapshots_lower.txt:2270:      label: for (var iter = __forAwait(y), more, temp, error; more = !(temp = await iter.next()).done; more = false) {
internal/runtime/runtime.go:38:	//   __asyncGenerator
internal/runtime/runtime.go:417:		export var __asyncGenerator = (__this, __arguments, generator) => {
internal/runtime/runtime.go:437:		export var __yieldStar = value => {
internal/runtime/runtime.go:469:		export var __forAwait = (obj, it, method) =>
internal/js_parser/js_parser.go:14765:		// "yield* x" turns into "yield* __yieldStar(x)" when lowering async generator functions
internal/js_parser/js_parser.go:14767:			e.ValueOrNil = p.callRuntime(expr.Loc, "__yieldStar", []js_ast.Expr{e.ValueOrNil})
internal/js_parser/js_parser_lower.go:478:			// "async function* foo(a, b) { stmts }" => "function foo(a, b) { return __asyncGenerator(this, null, function* () { stmts }) }"
internal/js_parser/js_parser_lower.go:479:			name = "__asyncGenerator"
internal/js_parser/js_parser_lower.go:1078:	//     for (var iter = __forAwait(y), more, temp, error; more = !(temp = await iter.next()).done; more = false) {
internal/js_parser/js_parser_lower.go:1166:						ValueOrNil: p.callRuntime(loc, "__forAwait", []js_ast.Expr{loop.Value})},
shell
git status --short
output
Chunk ID: 2fa366
Wall time: 0.0000 seconds
Process exited with code 128
Original token count: 18
Output:
fatal: not a git repository (or any of the parent directories): .git
shell
sed -n '1,260p' internal/runtime/runtime.go
output
Chunk ID: a19bf5
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 2542
Output:
package runtime

// This is esbuild's runtime code. It contains helper functions that are
// automatically injected into output files to implement certain features. For
// example, the "**" operator is replaced with a call to "__pow" when targeting
// ES2015. Tree shaking automatically removes unused code from the runtime.

import (
	"[code-host]/evanw/esbuild/internal/compat"
	"[code-host]/evanw/esbuild/internal/logger"
)

// The runtime source is always at a special index. The index is always zero
// but this constant is always used instead to improve readability and ensure
// all code that references this index can be discovered easily.
const SourceIndex = uint32(0)

func Source(unsupportedJSFeatures compat.JSFeature) logger.Source {
	// Note: These helper functions used to be named similar things to the helper
	// functions from the TypeScript compiler. However, people sometimes use these
	// two projects in combination and TypeScript's implementation of these helpers
	// causes name collisions. Some examples:
	//
	// * The "tslib" library will overwrite esbuild's helper functions if the bundled
	//   code is run in the global scope: https://[code-host]/evanw/esbuild/issues/1102
	//
	// * Running the TypeScript compiler on esbuild's output to convert ES6 to ES5
	//   will also overwrite esbuild's helper functions because TypeScript doesn't
	//   change the names of its helper functions to avoid name collisions:
	//   https://[code-host]/microsoft/TypeScript/issues/43296
	//
	// These can both be considered bugs in TypeScript. However, they are unlikely
	// to be fixed and it's simplest to just avoid using the same names to avoid
	// these bugs. Forbidden names (from "tslib"):
	//
	//   __assign
	//   __asyncDelegator
	//   __asyncGenerator
	//   __asyncValues
	//   __await
	//   __awaiter
	//   __classPrivateFieldGet
	//   __classPrivateFieldSet
	//   __createBinding
	//   __decorate
	//   __exportStar
	//   __extends
	//   __generator
	//   __importDefault
	//   __importStar
	//   __makeTemplateObject
	//   __metadata
	//   __param
	//   __read
	//   __rest
	//   __spread
	//   __spreadArray
	//   __spreadArrays
	//   __values
	//
	// Note: The "__objRest" function has a for-of loop which requires ES6, but
	// transforming destructuring to ES5 isn't even supported so it's ok.
	text := `
		var __create = Object.create
		var __freeze = Object.freeze
		var __defProp = Object.defineProperty
		var __defProps = Object.defineProperties
		var __getOwnPropDesc = Object.getOwnPropertyDescriptor // Note: can return "undefined" due to a Safari bug
		var __getOwnPropDescs = Object.getOwnPropertyDescriptors
		var __getOwnPropNames = Object.getOwnPropertyNames
		var __getOwnPropSymbols = Object.getOwnPropertySymbols
		var __getProtoOf = Object.getPrototypeOf
		var __hasOwnProp = Object.prototype.hasOwnProperty
		var __propIsEnum = Object.prototype.propertyIsEnumerable
		var __reflectGet = Reflect.get
		var __reflectSet = Reflect.set

		var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for('Symbol.' + name)
		var __typeError = msg => { throw TypeError(msg) }

		export var __pow = Math.pow

		var __defNormalProp = (obj, key, value) => key in obj
			? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value})
			: obj[key] = value

		export var __spreadValues = (a, b) => {
			for (var prop in b ||= {})
				if (__hasOwnProp.call(b, prop))
					__defNormalProp(a, prop, b[prop])
			if (__getOwnPropSymbols)
		`

	// Avoid "of" when not using ES6
	if !unsupportedJSFeatures.Has(compat.ForOf) {
		text += `
				for (var prop of __getOwnPropSymbols(b)) {
		`
	} else {
		text += `
				for (var props = __getOwnPropSymbols(b), i = 0, n = props.length, prop; i < n; i++) {
					prop = props[i]
		`
	}

	text += `
					if (__propIsEnum.call(b, prop))
						__defNormalProp(a, prop, b[prop])
				}
			return a
		}
		export var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b))

		// Update the "name" property on the function or class for "--keep-names"
		export var __name = (target, value) => __defProp(target, 'name', { value, configurable: true })

		// This fallback "require" function exists so that "typeof require" can
		// naturally be "function" even in non-CommonJS environments since esbuild
		// emulates a CommonJS environment (issue #1202). However, people want this
		// shim to fall back to "globalThis.require" even if it's defined later
		// (including property accesses such as "require.resolve") so we need to
		// use a proxy (issue #1614).
		export var __require =
			/* @__PURE__ */ (x =>
				typeof require !== 'undefined' ? require :
				typeof Proxy !== 'undefined' ? new Proxy(x, {
					get: (a, b) => (typeof require !== 'undefined' ? require : a)[b]
				}) : x
			)(function(x) {
				if (typeof require !== 'undefined') return require.apply(this, arguments)
				throw Error('Dynamic require of "' + x + '" is not supported')
			})

		// This is used for glob imports
		export var __glob = map => path => {
			var fn = map[path]
			if (fn) return fn()
			throw new Error('Module not found in bundle: ' + path)
		}

		// For object rest patterns
		export var __restKey = key => typeof key === 'symbol' ? key : key + ''
		export var __objRest = (source, exclude) => {
			var target = {}
			for (var prop in source)
				if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
					target[prop] = source[prop]
			if (source != null && __getOwnPropSymbols)
	`

	// Avoid "of" when not using ES6
	if !unsupportedJSFeatures.Has(compat.ForOf) {
		text += `
				for (var prop of __getOwnPropSymbols(source)) {
		`
	} else {
		text += `
				for (var props = __getOwnPropSymbols(source), i = 0, n = props.length, prop; i < n; i++) {
					prop = props[i]
		`
	}

	text += `
					if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
						target[prop] = source[prop]
				}
			return target
		}

		// This is for lazily-initialized ESM code. This has two implementations, a
		// compact one for minified code and a verbose one that generates friendly
		// names in V8's profiler and in stack traces.
		export var __esm = (fn, res) => function __init() {
			return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res
		}
		export var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res)

		// Wraps a CommonJS closure and returns a require() function. This has two
		// implementations, a compact one for minified code and a verbose one that
		// generates friendly names in V8's profiler and in stack traces.
		export var __commonJS = (cb, mod) => function __require() {
			return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = {exports: {}}).exports, mod), mod.exports
		}
		export var __commonJSMin = (cb, mod) => () => (mod || cb((mod = {exports: {}}).exports, mod), mod.exports)

		// Used to implement ESM exports both for "require()" and "import * as"
		export var __export = (target, all) => {
			for (var name in all)
				__defProp(target, name, { get: all[name], enumerable: true })
		}

		var __copyProps = (to, from, except, desc) => {
			if (from && typeof from === 'object' || typeof from === 'function')
	`

	// Avoid "let" when not using ES6
	if !unsupportedJSFeatures.Has(compat.ForOf) && !unsupportedJSFeatures.Has(compat.ConstAndLet) {
		text += `
				for (let key of __getOwnPropNames(from))
					if (!__hasOwnProp.call(to, key) && key !== except)
						__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable })
		`
	} else {
		text += `
				for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
					key = keys[i]
					if (!__hasOwnProp.call(to, key) && key !== except)
						__defProp(to, key, { get: (k => from[k]).bind(null, key), enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable })
				}
		`
	}

	text += `
			return to
		}

		// This is used to implement "export * from" statements. It copies properties
		// from the imported module to the current module's ESM export object. If the
		// current module is an entry point and the target format is CommonJS, we
		// also copy the properties to "module.exports" in addition to our module's
		// internal ESM export object.
		export var __reExport = (target, mod, secondTarget) => (
			__copyProps(target, mod, 'default'),
			secondTarget && __copyProps(secondTarget, mod, 'default')
		)

		// Converts the module from CommonJS to ESM. When in node mode (i.e. in an
		// ".mjs" file, package.json has "type: module", or the "__esModule" export
		// in the CommonJS file is falsy or missing), the "default" property is
		// overridden to point to the original CommonJS exports object instead.
		export var __toESM = (mod, isNodeMode, target) => (
			target = mod != null ? __create(__getProtoOf(mod)) : {},
			__copyProps(
				// If the importer is in node compatibility mode or this is not an ESM
				// file that has been converted to a CommonJS file using a Babel-
				// compatible transform (i.e. "__esModule" has not been set), then set
				// "default" to the CommonJS "module.exports" for node compatibility.
				isNodeMode || !mod || !mod.__esModule
					? __defProp(target, 'default', { value: mod, enumerable: true })
					: target,
				mod)
		)

		// Converts the module from ESM to CommonJS. This clones the input module
		// object with the addition of a non-enumerable "__esModule" property set
		// to "true", which overwrites any existing export named "__esModule".
		export var __toCommonJS = mod => __copyProps(__defProp({}, '__esModule', { value: true }), mod)

		// For TypeScript experimental decorators
		// - kind === undefined: class
		// - kind === 1: method, parameter
		// - kind === 2: field
		export var __decorateClass = (decorators, target, key, kind) => {
			var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target
			for (var i = decorators.length - 1, decorator; i >= 0; i--)
				if (decorator = decorators[i])
					result = (kind ? decorator(target, key, result) : decorator(result)) || result
			if (kind && result) __defProp(target, key, result)
			return result
		}
The repository isn’t a git checkout in this container, so I’ll avoid relying on git metadata. The helper definitions are in the expected place; next I’m narrowing in on their current control flow and the parser tests that snapshot lowered output.
shell
sed -n '390,490p' internal/runtime/runtime.go
output
Chunk ID: 1209cc
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 821
Output:
		// This helps for lowering async functions
		export var __async = (__this, __arguments, generator) => {
			return new Promise((resolve, reject) => {
				var fulfilled = value => {
					try {
						step(generator.next(value))
					} catch (e) {
						reject(e)
					}
				}
				var rejected = value => {
					try {
						step(generator.throw(value))
					} catch (e) {
						reject(e)
					}
				}
				var step = x => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected)
				step((generator = generator.apply(__this, __arguments)).next())
			})
		}

		// These help for lowering async generator functions
		export var __await = function (promise, isYieldStar) {
			this[0] = promise
			this[1] = isYieldStar
		}
		export var __asyncGenerator = (__this, __arguments, generator) => {
			var resume = (k, v, yes, no) => {
				try {
					var x = generator[k](v), isAwait = (v = x.value) instanceof __await, done = x.done
					Promise.resolve(isAwait ? v[0] : v)
						.then(y => isAwait
							? resume(k === 'return' ? k : 'next', v[1] ? { done: y.done, value: y.value } : y, yes, no)
							: yes({ value: y, done }))
						.catch(e => resume('throw', e, yes, no))
				} catch (e) {
					no(e)
				}
			}, method = k => it[k] = x => new Promise((yes, no) => resume(k, x, yes, no)), it = {}
			return generator = generator.apply(__this, __arguments),
				it[__knownSymbol('asyncIterator')] = () => it,
				method('next'),
				method('throw'),
				method('return'),
				it
		}
		export var __yieldStar = value => {
			var obj = value[__knownSymbol('asyncIterator')], isAwait = false, method, it = {}
			if (obj == null) {
				obj = value[__knownSymbol('iterator')]()
				method = k => it[k] = x => obj[k](x)
			} else {
				obj = obj.call(value)
				method = k => it[k] = v => {
					if (isAwait) {
						isAwait = false
						if (k === 'throw') throw v
						return v
					}
					isAwait = true
					return {
						done: false,
						value: new __await(new Promise(resolve => {
							var x = obj[k](v)
							if (!(x instanceof Object)) __typeError('Object expected')
							resolve(x)
						}), 1),
					}
				}
			}
			return it[__knownSymbol('iterator')] = () => it,
				method('next'),
				'throw' in obj ? method('throw') : it.throw = x => { throw x },
				'return' in obj && method('return'),
				it
		}

		// This helps for lowering for-await loops
		export var __forAwait = (obj, it, method) =>
			(it = obj[__knownSymbol('asyncIterator')])
				? it.call(obj)
				: (obj = obj[__knownSymbol('iterator')](),
					it = {},
					method = (key, fn) =>
						(fn = obj[key]) && (it[key] = arg =>
							new Promise((yes, no, done) => (
								arg = fn.call(obj, arg),
								done = arg.done,
								Promise.resolve(arg.value)
									.then(value => yes({ value, done }), no)
							))),
					method('next'),
					method('return'),
					it)

		// This is for the "binary" loader (custom code is ~2x faster than "atob")
		export var __toBinaryNode = Uint8Array.fromBase64 || (base64 => new Uint8Array(Buffer.from(base64, 'base64')))
		export var __toBinary = Uint8Array.fromBase64 || /* @__PURE__ */ (() => {
			var table = new Uint8Array(128)
			for (var i = 0; i < 64; i++) table[i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i * 4 - 205] = i
shell
rg -n "AsyncGenerator|async generator|yield\*|for-await|ForAwait|Lower" internal/*_tests internal -g '*_test.go'
output
Chunk ID: 11f419
Wall time: 0.0001 seconds
Process exited with code 0
Original token count: 18460
Output:
Total output lines: 525

internal/bundler_tests/bundler_dce_test.go:2349:func TestTreeShakingLoweredClassStaticField(t *testing.T) {
internal/bundler_tests/bundler_dce_test.go:2383:func TestTreeShakingLoweredClassStaticFieldMinified(t *testing.T) {
internal/bundler_tests/bundler_dce_test.go:2419:func TestTreeShakingLoweredClassStaticFieldAssignment(t *testing.T) {
internal/bundler_tests/bundler_dce_test.go:2349:func TestTreeShakingLoweredClassStaticField(t *testing.T) {
internal/bundler_tests/bundler_dce_test.go:2383:func TestTreeShakingLoweredClassStaticFieldMinified(t *testing.T) {
internal/bundler_tests/bundler_dce_test.go:2419:func TestTreeShakingLoweredClassStaticFieldAssignment(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:18:func TestLowerOptionalCatchNameCollisionNoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:35:func TestLowerObjectSpreadNoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:63:func TestLowerExponentiationOperatorNoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:108:func TestLowerPrivateFieldAssignments2015NoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:149:func TestLowerPrivateFieldAssignments2019NoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:190:func TestLowerPrivateFieldAssignments2020NoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:231:func TestLowerPrivateFieldAssignmentsNextNoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:271:func TestLowerPrivateFieldOptionalChain2019NoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:293:func TestLowerPrivateFieldOptionalChain2020NoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:315:func TestLowerPrivateFieldOptionalChainNextNoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:336:func TestTSLowerPrivateFieldOptionalChain2015NoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:358:func TestTSLowerPrivateStaticMembers2015NoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:383:func TestTSLowerPrivateFieldAndMethodAvoidNameCollision2015(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:404:func TestLowerPrivateGetterSetter2015(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:455:func TestLowerPrivateGetterSetter2019(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:506:func TestLowerPrivateGetterSetter2020(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:557:func TestLowerPrivateGetterSetterNext(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:607:func TestLowerPrivateMethod2019(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:649:func TestLowerPrivateMethod2020(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:691:func TestLowerPrivateMethodNext(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:732:func TestLowerPrivateClassExpr2020NoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:756:func TestLowerPrivateMethodWithModifiers2020(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:780:func TestLowerAsync2016NoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:825:func TestLowerAsync2017NoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:858:func TestLowerAsyncThis2016CommonJS(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:874:func TestLowerAsyncThis2016ES6(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:898:func TestLowerAsyncES5(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:935:func TestLowerAsyncSuperES2017NoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1011:func TestLowerAsyncSuperES2016NoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1087:func TestLowerStaticAsyncSuperES2021NoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1153:func TestLowerStaticAsyncSuperES2016NoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1219:func TestLowerStaticSuperES2021NoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1271:func TestLowerStaticSuperES2016NoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1323:func TestLowerAsyncArrowSuperES2016(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1368:func TestLowerAsyncArrowSuperSetterES2016(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1413:func TestLowerStaticAsyncArrowSuperES2016(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1458:func TestLowerStaticAsyncArrowSuperSetterES2016(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1503:func TestLowerPrivateSuperES2022(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1534:func TestLowerPrivateSuperES2021(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1566:func TestLowerPrivateSuperStaticBundleIssue2158(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1587:func TestLowerClassField2020NoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1611:func TestLowerClassFieldNextNoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1634:func TestTSLowerClassField2020NoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1663:func TestTSLowerClassPrivateFieldNextNoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1691:func TestLowerClassFieldStrictTsconfigJson2020(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1733:func TestTSLowerClassFieldStrictTsconfigJson2020(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1775:func TestTSLowerObjectRest2017NoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1823:func TestTSLowerObjectRest2018NoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1897:func TestLowerExportStarAsNameCollisionNoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1914:func TestLowerExportStarAsNameCollision(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1945:func TestLowerStrictModeSyntax(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1966:func TestLowerForbidStrictModeSyntax(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2001:func TestLowerPrivateClassFieldOrder(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2021:func TestLowerPrivateClassMethodOrder(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2041:func TestLowerPrivateClassAccessorOrder(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2061:func TestLowerPrivateClassStaticFieldOrder(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2087:func TestLowerPrivateClassStaticMethodOrder(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2113:func TestLowerPrivateClassStaticAccessorOrder(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2139:func TestLowerPrivateClassBrandCheckUnsupported(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2165:func TestLowerPrivateClassBrandCheckSupported(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2190:func TestLowerTemplateObject(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2218:func TestLowerPrivateClassFieldStaticIssue1424(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2241:func TestLowerNullishCoalescingAssignmentIssue1493(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2325:func TestLowerRegExpNameCollision(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2343:func TestLowerForAwait2017(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2366:func TestLowerForAwait2015(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2389:func TestLowerNestedFunctionDirectEval(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2645:func TestLowerUsing(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2709:func TestLowerUsingUnsupportedAsync(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2758:func TestLowerUsingUnsupportedUsingAndAsync(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2807:func TestLowerUsingHoisting(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2978:func TestLowerUsingInsideTSNamespace(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2998:func TestLowerAsyncGenerator(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:3053:			UnsupportedJSFeatures: compat.AsyncGenerator,
internal/bundler_tests/bundler_lower_test.go:3058:func TestLowerAsyncGeneratorNoAwait(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:3113:			UnsupportedJSFeatures: compat.AsyncGenerator | compat.AsyncAwait,
internal/bundler_tests/bundler_lower_test.go:3148:func TestForAwaitWithOptionalCatchIssue4378(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:3161:			UnsupportedJSFeatures: compat.ForAwait,
internal/bundler_tests/bundler_lower_test.go:18:func TestLowerOptionalCatchNameCollisionNoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:35:func TestLowerObjectSpreadNoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:63:func TestLowerExponentiationOperatorNoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:108:func TestLowerPrivateFieldAssignments2015NoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:149:func TestLowerPrivateFieldAssignments2019NoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:190:func TestLowerPrivateFieldAssignments2020NoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:231:func TestLowerPrivateFieldAssignmentsNextNoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:271:func TestLowerPrivateFieldOptionalChain2019NoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:293:func TestLowerPrivateFieldOptionalChain2020NoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:315:func TestLowerPrivateFieldOptionalChainNextNoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:336:func TestTSLowerPrivateFieldOptionalChain2015NoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:358:func TestTSLowerPrivateStaticMembers2015NoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:383:func TestTSLowerPrivateFieldAndMethodAvoidNameCollision2015(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:404:func TestLowerPrivateGetterSetter2015(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:455:func TestLowerPrivateGetterSetter2019(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:506:func TestLowerPrivateGetterSetter2020(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:557:func TestLowerPrivateGetterSetterNext(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:607:func TestLowerPrivateMethod2019(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:649:func TestLowerPrivateMethod2020(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:691:func TestLowerPrivateMethodNext(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:732:func TestLowerPrivateClassExpr2020NoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:756:func TestLowerPrivateMethodWithModifiers2020(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:780:func TestLowerAsync2016NoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:825:func TestLowerAsync2017NoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:858:func TestLowerAsyncThis2016CommonJS(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:874:func TestLowerAsyncThis2016ES6(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:898:func TestLowerAsyncES5(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:935:func TestLowerAsyncSuperES2017NoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1011:func TestLowerAsyncSuperES2016NoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1087:func TestLowerStaticAsyncSuperES2021NoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1153:func TestLowerStaticAsyncSuperES2016NoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1219:func TestLowerStaticSuperES2021NoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1271:func TestLowerStaticSuperES2016NoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1323:func TestLowerAsyncArrowSuperES2016(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1368:func TestLowerAsyncArrowSuperSetterES2016(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1413:func TestLowerStaticAsyncArrowSuperES2016(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1458:func TestLowerStaticAsyncArrowSuperSetterES2016(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1503:func TestLowerPrivateSuperES2022(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1534:func TestLowerPrivateSuperES2021(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1566:func TestLowerPrivateSuperStaticBundleIssue2158(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1587:func TestLowerClassField2020NoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1611:func TestLowerClassFieldNextNoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1634:func TestTSLowerClassField2020NoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1663:func TestTSLowerClassPrivateFieldNextNoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1691:func TestLowerClassFieldStrictTsconfigJson2020(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1733:func TestTSLowerClassFieldStrictTsconfigJson2020(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1775:func TestTSLowerObjectRest2017NoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1823:func TestTSLowerObjectRest2018NoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1897:func TestLowerExportStarAsNameCollisionNoBundle(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1914:func TestLowerExportStarAsNameCollision(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1945:func TestLowerStrictModeSyntax(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:1966:func TestLowerForbidStrictModeSyntax(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2001:func TestLowerPrivateClassFieldOrder(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2021:func TestLowerPrivateClassMethodOrder(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2041:func TestLowerPrivateClassAccessorOrder(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2061:func TestLowerPrivateClassStaticFieldOrder(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2087:func TestLowerPrivateClassStaticMethodOrder(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2113:func TestLowerPrivateClassStaticAccessorOrder(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2139:func TestLowerPrivateClassBrandCheckUnsupported(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2165:func TestLowerPrivateClassBrandCheckSupported(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2190:func TestLowerTemplateObject(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2218:func TestLowerPrivateClassFieldStaticIssue1424(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2241:func TestLowerNullishCoalescingAssignmentIssue1493(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2325:func TestLowerRegExpNameCollision(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2343:func TestLowerForAwait2017(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2366:func TestLowerForAwait2015(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2389:func TestLowerNestedFunctionDirectEval(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2645:func TestLowerUsing(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2709:func TestLowerUsingUnsupportedAsync(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2758:func TestLowerUsingUnsupportedUsingAndAsync(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2807:func TestLowerUsingHoisting(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2978:func TestLowerUsingInsideTSNamespace(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2998:func TestLowerAsyncGenerator(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:3053:			UnsupportedJSFeatures: compat.AsyncGenerator,
internal/bundler_tests/bundler_lower_test.go:3058:func TestLowerAsyncGeneratorNoAwait(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:3113:			UnsupportedJSFeatures: compat.AsyncGenerator | compat.AsyncAwait,
internal/bundler_tests/bundler_lower_test.go:3148:func TestForAwaitWithOptionalCatchIssue4378(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:3161:			UnsupportedJSFeatures: compat.ForAwait,
internal/bundler_tests/bundler_ts_test.go:1759:func TestTSComputedClassFieldUseDefineTrueLower(t *testing.T) {
internal/bundler_tests/bundler_css_test.go:427:func TestImportCSSFromJSLowerBareLocalAndGlobal(t *testing.T) {
internal/bundler_tests/bundler_ts_test.go:1759:func TestTSComputedClassFieldUseDefineTrueLower(t *testing.T) {
internal/bundler_tests/bundler_css_test.go:427:func TestImportCSSFromJSLowerBareLocalAndGlobal(t *testing.T) {
internal/bundler_tests/bundler_default_test.go:5460:func TestDefineOptionalChainLowered(t *testing.T) {
internal/bundler_tests/bundler_default_test.go:5905:func TestForbidConstAssignWhenLoweringUsing(t *testing.T) {
internal/bundler_tests/bundler_default_test.go:7219:func TestManglePropsLoweredOptionalChain(t *testing.T) {
internal/bundler_tests/bundler_default_test.go:7581:func TestManglePropsLoweredClassFields(t *testing.T) {
internal/bundler_tests/bundler_default_test.go:5460:func TestDefineOptionalChainLowered(t *testing.T) {
internal/bundler_tests/bundler_default_test.go:5905:func TestForbidConstAssignWhenLoweringUsing(t *testing.T) {
internal/bundler_tests/bundler_default_test.go:7219:func TestManglePropsLoweredOptionalChain(t *testing.T) {
internal/bundler_tests/bundler_default_test.go:7581:func TestManglePropsLoweredClassFields(t *testing.T) {
internal/css_parser/css_parser_test.go:47:func expectPrintedLower(t *testing.T, contents string, expected string, expectedLog string) {
internal/css_parser/css_parser_test.go:54:func expectPrintedLowerUnsupported(t *testing.T, unsupportedCSSFeatures compat.CSSFeature, contents string, expected string, expectedLog string) {
internal/css_parser/css_parser_test.go:90:func expectPrintedLowerMangle(t *testing.T, contents string, expected string, expectedLog string) {
internal/css_parser/css_parser_test.go:106:func expectPrintedLowerMinify(t *testing.T, contents string, expected string, expectedLog string) {
internal/css_parser/css_parser_test.go:535:	expectPrintedLower(t, "a { before: 0; color: color(display-p3 1 0 0); after: 1 }",
internal/css_parser/css_parser_test.go:537:	expectPrintedLowerMangle(t, "a { before: 0; color: color(display-p3 1 0 0); after: 1 }",
internal/css_parser/css_parser_test.go:539:	expectPrintedLower(t, "a { before: 0; color: color(display-p3 1 0 0 / 0.5); after: 1 }",
internal/css_parser/css_parser_test.go:541:	expectPrintedLowerMangle(t, "a { before: 0; color: color(display-p3 1 0 0 / 0.5); after: 1 }",
internal/css_parser/css_parser_test.go:543:	expectPrintedLower(t, "a { before: 0; background: color(display-p3 1 0 0); after: 1 }",
internal/css_parser/css_parser_test.go:545:	expectPrintedLowerMangle(t, "a { before: 0; background: color(display-p3 1 0 0); after: 1 }",
internal/css_parser/css_parser_test.go:547:	expectPrintedLower(t, "a { before: 0; …8460 tokens truncated…supported(t, nesting, ".foo { &&& .bar { color: red } }", ".foo.foo.foo .bar {\n  color: red;\n}\n", "")
internal/css_parser/css_parser_test.go:1282:	expectPrintedLowerUnsupported(t, nesting, ".foo { .bar&&& { color: red } }", ".foo.foo.foo.bar {\n  color: red;\n}\n", "")
internal/css_parser/css_parser_test.go:1283:	expectPrintedLowerUnsupported(t, nesting, ".foo { .bar &&& { color: red } }", ".bar .foo.foo.foo {\n  color: red;\n}\n", "")
internal/css_parser/css_parser_test.go:1284:	expectPrintedLowerUnsupported(t, nesting, ".foo { &.bar&.baz& { color: red } }", ".foo.foo.foo.bar.baz {\n  color: red;\n}\n", "")
internal/css_parser/css_parser_test.go:1285:	expectPrintedLowerUnsupported(t, nesting, "a { &&&.bar { color: red } }", "a:is(a):is(a).bar {\n  color: red;\n}\n", "")
internal/css_parser/css_parser_test.go:1286:	expectPrintedLowerUnsupported(t, nesting, "a { &&& .bar { color: red } }", "a:is(a):is(a) .bar {\n  color: red;\n}\n", "")
internal/css_parser/css_parser_test.go:1287:	expectPrintedLowerUnsupported(t, nesting, "a { .bar&&& { color: red } }", "a:is(a):is(a).bar {\n  color: red;\n}\n", "")
internal/css_parser/css_parser_test.go:1288:	expectPrintedLowerUnsupported(t, nesting, "a { .bar &&& { color: red } }", ".bar a:is(a):is(a) {\n  color: red;\n}\n", "")
internal/css_parser/css_parser_test.go:1289:	expectPrintedLowerUnsupported(t, nesting, "a { &.bar&.baz& { color: red } }", "a:is(a):is(a).bar.baz {\n  color: red;\n}\n", "")
internal/css_parser/css_parser_test.go:1290:	expectPrintedLowerUnsupported(t, nesting, "a, b { &&&.bar { color: red } }", ":is(a, b):is(a, b):is(a, b).bar {\n  color: red;\n}\n", "")
internal/css_parser/css_parser_test.go:1291:	expectPrintedLowerUnsupported(t, nesting, "a, b { &&& .bar { color: red } }", ":is(a, b):is(a, b):is(a, b) .bar {\n  color: red;\n}\n", "")
internal/css_parser/css_parser_test.go:1292:	expectPrintedLowerUnsupported(t, nesting, "a, b { .bar&&& { color: red } }", ":is(a, b):is(a, b):is(a, b).bar {\n  color: red;\n}\n", "")
internal/css_parser/css_parser_test.go:1293:	expectPrintedLowerUnsupported(t, nesting, "a, b { .bar &&& { color: red } }", ".bar :is(a, b):is(a, b):is(a, b) {\n  color: red;\n}\n", "")
internal/css_parser/css_parser_test.go:1294:	expectPrintedLowerUnsupported(t, nesting, "a, b { &.bar&.baz& { color: red } }", ":is(a, b):is(a, b):is(a, b).bar.baz {\n  color: red;\n}\n", "")
internal/css_parser/css_parser_test.go:1295:	expectPrintedLowerUnsupported(t, nesting, ".foo { &, &&.bar, &&& .baz { color: red } }", ".foo,\n.foo.foo.bar,\n.foo.foo.foo .baz {\n  color: red;\n}\n", "")
internal/css_parser/css_parser_test.go:1298:	expectPrintedLower(t, ".card { &--header { color: red } }", ".card {\n  &--header {\n    color: red;\n  }\n}\n",
internal/css_parser/css_parser_test.go:1300:	expectPrintedLower(t, ".card { &__header { color: red } }", ".card {\n  &__header {\n    color: red;\n  }\n}\n",
internal/css_parser/css_parser_test.go:1302:	expectPrintedLower(t, ".card { .nav &--header { color: red } }", ".card {\n  .nav &--header {\n    color: red;\n  }\n}\n",
internal/css_parser/css_parser_test.go:1304:	expectPrintedLower(t, ".card { .nav &__header { color: red } }", ".card {\n  .nav &__header {\n    color: red;\n  }\n}\n",
internal/css_parser/css_parser_test.go:1314:	expectPrintedLower(t, "a, b::before { &.foo { color: red } }", "a.foo {\n  color: red;\n}\n", "")
internal/css_parser/css_parser_test.go:1315:	expectPrintedLower(t, "a, b::before { & .foo { color: red } }", "a .foo {\n  color: red;\n}\n", "")
internal/css_parser/css_parser_test.go:1316:	expectPrintedLower(t, "a { &.foo, &::before { color: red } }", "a.foo,\na::before {\n  color: red;\n}\n", "")
internal/css_parser/css_parser_test.go:1317:	expectPrintedLower(t, "a { & .foo, & ::before { color: red } }", "a .foo,\na ::before {\n  color: red;\n}\n", "")
internal/css_parser/css_parser_test.go:1318:	expectPrintedLower(t, "a, b::before { color: blue; &.foo, &::after { color: red } }", "a,\nb::before {\n  color: blue;\n}\na.foo,\na::after {\n  color: red;\n}\n", "")
internal/css_parser/css_parser_test.go:1321:	expectPrintedLower(t, ".foo { @media screen {} }", "", "")
internal/css_parser/css_parser_test.go:1322:	expectPrintedLower(t, ".foo { @media screen { color: red } }", "@media screen {\n  .foo {\n    color: red;\n  }\n}\n", "")
internal/css_parser/css_parser_test.go:1323:	expectPrintedLower(t, ".foo { @media screen { &:hover { color: red } } }", "@media screen {\n  .foo:hover {\n    color: red;\n  }\n}\n", "")
internal/css_parser/css_parser_test.go:1324:	expectPrintedLower(t, ".foo { @media screen { :hover { color: red } } }", "@media screen {\n  .foo :hover {\n    color: red;\n  }\n}\n", "")
internal/css_parser/css_parser_test.go:1325:	expectPrintedLower(t, ".foo, .bar { @media screen { color: red } }", "@media screen {\n  .foo,\n  .bar {\n    color: red;\n  }\n}\n", "")
internal/css_parser/css_parser_test.go:1326:	expectPrintedLower(t, ".foo, .bar { @media screen { &:hover { color: red } } }", "@media screen {\n  .foo:hover,\n  .bar:hover {\n    color: red;\n  }\n}\n", "")
internal/css_parser/css_parser_test.go:1327:	expectPrintedLower(t, ".foo, .bar { @media screen { :hover { color: red } } }", "@media screen {\n  .foo :hover,\n  .bar :hover {\n    color: red;\n  }\n}\n", "")
internal/css_parser/css_parser_test.go:1328:	expectPrintedLower(t, ".foo { @layer xyz {} }", "@layer xyz;\n", "")
internal/css_parser/css_parser_test.go:1329:	expectPrintedLower(t, ".foo { @layer xyz { color: red } }", "@layer xyz {\n  .foo {\n    color: red;\n  }\n}\n", "")
internal/css_parser/css_parser_test.go:1330:	expectPrintedLower(t, ".foo { @layer xyz { &:hover { color: red } } }", "@layer xyz {\n  .foo:hover {\n    color: red;\n  }\n}\n", "")
internal/css_parser/css_parser_test.go:1331:	expectPrintedLower(t, ".foo { @layer xyz { :hover { color: red } } }", "@layer xyz {\n  .foo :hover {\n    color: red;\n  }\n}\n", "")
internal/css_parser/css_parser_test.go:1332:	expectPrintedLower(t, ".foo, .bar { @layer xyz { color: red } }", "@layer xyz {\n  .foo,\n  .bar {\n    color: red;\n  }\n}\n", "")
internal/css_parser/css_parser_test.go:1333:	expectPrintedLower(t, ".foo, .bar { @layer xyz { &:hover { color: red } } }", "@layer xyz {\n  .foo:hover,\n  .bar:hover {\n    color: red;\n  }\n}\n", "")
internal/css_parser/css_parser_test.go:1334:	expectPrintedLower(t, ".foo, .bar { @layer xyz { :hover { color: red } } }", "@layer xyz {\n  .foo :hover,\n  .bar :hover {\n    color: red;\n  }\n}\n", "")
internal/css_parser/css_parser_test.go:1335:	expectPrintedLower(t, "@media screen { @media (min-width: 900px) { a, b { &:hover { color: red } } } }",
internal/css_parser/css_parser_test.go:1337:	expectPrintedLower(t, "@supports (display: flex) { @supports selector(h2 > p) { a, b { &:hover { color: red } } } }",
internal/css_parser/css_parser_test.go:1339:	expectPrintedLower(t, "@layer foo { @layer bar { a, b { &:hover { color: red } } } }",
internal/css_parser/css_parser_test.go:1341:	expectPrintedLower(t, ".card { @supports (selector(&)) { &:hover { color: red } } }",
internal/css_parser/css_parser_test.go:1343:	expectPrintedLower(t, "html { @layer base { color: blue; @layer support { & body { color: red } } } }",
internal/css_parser/css_parser_test.go:1352:	expectPrintedLower(t, "::placeholder { color: red; body & { color: green } }",
internal/css_parser/css_parser_test.go:1354:	expectPrintedLower(t, "::placeholder { color: red; @supports (color: green) { color: green } }",
internal/css_parser/css_parser_test.go:1356:	expectPrintedLower(t, "::placeholder { opacity: 0.5; @layer base { color: green } }",
internal/css_parser/css_parser_test.go:1652:func TestLowerAtImportMediaRange(t *testing.T) {
internal/css_parser/css_parser_test.go:1654:	expectPrintedLower(t, "@import \"foo.css\" (1px<=width<=2px);", "@import \"foo.css\" (min-width: 1px) and (max-width: 2px);\n", "")
internal/css_parser/css_parser_test.go:1984:	expectPrintedLowerMangle(t, "a { top: 0; right: 0; bottom: 0; left: 0; }", "a {\n  top: 0;\n  right: 0;\n  bottom: 0;\n  left: 0;\n}\n", "")
internal/css_parser/css_parser_test.go:1987:	expectPrintedLower(t, "a { inset: 0; }", "a {\n  top: 0;\n  right: 0;\n  bottom: 0;\n  left: 0;\n}\n", "")
internal/css_parser/css_parser_test.go:1988:	expectPrintedLower(t, "a { inset: 0px; }", "a {\n  top: 0px;\n  right: 0px;\n  bottom: 0px;\n  left: 0px;\n}\n", "")
internal/css_parser/css_parser_test.go:1989:	expectPrintedLower(t, "a { inset: 1px 2px; }", "a {\n  top: 1px;\n  right: 2px;\n  bottom: 1px;\n  left: 2px;\n}\n", "")
internal/css_parser/css_parser_test.go:1990:	expectPrintedLower(t, "a { inset: 1px 2px 3px; }", "a {\n  top: 1px;\n  right: 2px;\n  bottom: 3px;\n  left: 2px;\n}\n", "")
internal/css_parser/css_parser_test.go:1991:	expectPrintedLower(t, "a { inset: 1px 2px 3px 4px; }", "a {\n  top: 1px;\n  right: 2px;\n  bottom: 3px;\n  left: 4px;\n}\n", "")
internal/css_parser/css_parser_test.go:1994:	expectPrintedLowerMangle(t, "a { top: 0px; }", "a {\n  top: 0;\n}\n", "")
internal/css_parser/css_parser_test.go:1995:	expectPrintedLowerMangle(t, "a { right: 0px; }", "a {\n  right: 0;\n}\n", "")
internal/css_parser/css_parser_test.go:1996:	expectPrintedLowerMangle(t, "a { bottom: 0px; }", "a {\n  bottom: 0;\n}\n", "")
internal/css_parser/css_parser_test.go:1997:	expectPrintedLowerMangle(t, "a { left: 0px; }", "a {\n  left: 0;\n}\n", "")
internal/css_parser/css_parser_test.go:1998:	expectPrintedLowerMangle(t, "a { inset: 0px; }", "a {\n  top: 0;\n  right: 0;\n  bottom: 0;\n  left: 0;\n}\n", "")
internal/css_parser/css_parser_test.go:2001:	expectPrintedLowerMinify(t, "a { top: 0px; }", "a{top:0px}", "")
internal/css_parser/css_parser_test.go:2002:	expectPrintedLowerMinify(t, "a { right: 0px; }", "a{right:0px}", "")
internal/css_parser/css_parser_test.go:2003:	expectPrintedLowerMinify(t, "a { bottom: 0px; }", "a{bottom:0px}", "")
internal/css_parser/css_parser_test.go:2004:	expectPrintedLowerMinify(t, "a { left: 0px; }", "a{left:0px}", "")
internal/css_parser/css_parser_test.go:2005:	expectPrintedLowerMinify(t, "a { inset: 0px; }", "a{top:0px;right:0px;bottom:0px;left:0px}", "")
internal/css_parser/css_parser_test.go:2006:	expectPrintedLowerMinify(t, "a { inset: 1px 2px; }", "a{top:1px;right:2px;bottom:1px;left:2px}", "")
internal/css_parser/css_parser_test.go:2007:	expectPrintedLowerMinify(t, "a { inset: 1px 2px 3px; }", "a{top:1px;right:2px;bottom:3px;left:2px}", "")
internal/css_parser/css_parser_test.go:2008:	expectPrintedLowerMinify(t, "a { inset: 1px 2px 3px 4px; }", "a{top:1px;right:2px;bottom:3px;left:4px}", "")
internal/css_parser/css_parser_test.go:2450:		expectPrintedLowerMangle(t, fmt.Sprintf("a { color: #%08X }", i), "a {\n  color: rgba(0, 0, 0, "+alpha+");\n}\n", "")
internal/css_parser/css_parser_test.go:2454:	expectPrintedLowerMangle(t, "a { color: #000000FF }", "a {\n  color: #000;\n}\n", "")
internal/css_parser/css_parser_test.go:2720:func TestLowerAtMediaRange(t *testing.T) {
internal/css_parser/css_parser_test.go:2721:	expectPrintedLower(t, "@media (width = 1px) { a { color: red } }", "@media (width: 1px) {\n  a {\n    color: red;\n  }\n}\n", "")
internal/css_parser/css_parser_test.go:2723:	expectPrintedLower(t, "@media (width < 1px) { a { color: red } }", "@media not (min-width: 1px) {\n  a {\n    color: red;\n  }\n}\n", "")
internal/css_parser/css_parser_test.go:2724:	expectPrintedLower(t, "@media (width <= 1px) { a { color: red } }", "@media (max-width: 1px) {\n  a {\n    color: red;\n  }\n}\n", "")
internal/css_parser/css_parser_test.go:2725:	expectPrintedLower(t, "@media (width > 1px) { a { color: red } }", "@media not (max-width: 1px) {\n  a {\n    color: red;\n  }\n}\n", "")
internal/css_parser/css_parser_test.go:2726:	expectPrintedLower(t, "@media (width >= 1px) { a { color: red } }", "@media (min-width: 1px) {\n  a {\n    color: red;\n  }\n}\n", "")
internal/css_parser/css_parser_test.go:2728:	expectPrintedLower(t, "@media (1px > width) { a { color: red } }", "@media not (min-width: 1px) {\n  a {\n    color: red;\n  }\n}\n", "")
internal/css_parser/css_parser_test.go:2729:	expectPrintedLower(t, "@media (1px >= width) { a { color: red } }", "@media (max-width: 1px) {\n  a {\n    color: red;\n  }\n}\n", "")
internal/css_parser/css_parser_test.go:2730:	expectPrintedLower(t, "@media (1px < width) { a { color: red } }", "@media not (max-width: 1px) {\n  a {\n    color: red;\n  }\n}\n", "")
internal/css_parser/css_parser_test.go:2731:	expectPrintedLower(t, "@media (1px <= width) { a { color: red } }", "@media (min-width: 1px) {\n  a {\n    color: red;\n  }\n}\n", "")
internal/css_parser/css_parser_test.go:2733:	expectPrintedLower(t, "@media (1px < width < 2px) { a { color: red } }", "@media (not (max-width: 1px)) and (not (min-width: 2px)) {\n  a {\n    color: red;\n  }\n}\n", "")
internal/css_parser/css_parser_test.go:2734:	expectPrintedLower(t, "@media (2px > width > 1px) { a { color: red } }", "@media (not (min-width: 2px)) and (not (max-width: 1px)) {\n  a {\n    color: red;\n  }\n}\n", "")
internal/css_parser/css_parser_test.go:2735:	expectPrintedLower(t, "@media (1px <= width <= 2px) { a { color: red } }", "@media (min-width: 1px) and (max-width: 2px) {\n  a {\n    color: red;\n  }\n}\n", "")
internal/css_parser/css_parser_test.go:2736:	expectPrintedLower(t, "@media (2px >= width >= 1px) { a { color: red } }", "@media (max-width: 2px) and (min-width: 1px) {\n  a {\n    color: red;\n  }\n}\n", "")
internal/css_parser/css_parser_test.go:2738:	expectPrintedLower(t, "@media (1px < width <= 2px) { a { color: red } }", "@media (not (max-width: 1px)) and (max-width: 2px) {\n  a {\n    color: red;\n  }\n}\n", "")
internal/css_parser/css_parser_test.go:2739:	expectPrintedLower(t, "@media (2px > width >= 1px) { a { color: red } }", "@media (not (min-width: 2px)) and (min-width: 1px) {\n  a {\n    color: red;\n  }\n}\n", "")
internal/css_parser/css_parser_test.go:2740:	expectPrintedLower(t, "@media (1px <= width < 2px) { a { color: red } }", "@media (min-width: 1px) and (not (min-width: 2px)) {\n  a {\n    color: red;\n  }\n}\n", "")
internal/css_parser/css_parser_test.go:2741:	expectPrintedLower(t, "@media (2px >= width > 1px) { a { color: red } }", "@media (max-width: 2px) and (not (max-width: 1px)) {\n  a {\n    color: red;\n  }\n}\n", "")
internal/css_parser/css_parser_test.go:2743:	expectPrintedLower(t, "@media not (1px < width < 2px) { a { color: red } }", "@media not ((not (max-width: 1px)) and (not (min-width: 2px))) {\n  a {\n    color: red;\n  }\n}\n", "")
internal/css_parser/css_parser_test.go:2744:	expectPrintedLower(t, "@media not (2px > width > 1px) { a { color: red } }", "@media not ((not (min-width: 2px)) and (not (max-width: 1px))) {\n  a {\n    color: red;\n  }\n}\n", "")
internal/css_parser/css_parser_test.go:2745:	expectPrintedLower(t, "@media not (1px <= width <= 2px) { a { color: red } }", "@media not ((min-width: 1px) and (max-width: 2px)) {\n  a {\n    color: red;\n  }\n}\n", "")
internal/css_parser/css_parser_test.go:2746:	expectPrintedLower(t, "@media not (2px >= width >= 1px) { a { color: red } }", "@media not ((max-width: 2px) and (min-width: 1px)) {\n  a {\n    color: red;\n  }\n}\n", "")
internal/css_parser/css_parser_test.go:2748:	expectPrintedLowerMangle(t, "@media not (1px < width < 2px) { a { color: red } }", "@media (max-width: 1px) or (min-width: 2px) {\n  a {\n    color: red;\n  }\n}\n", "")
internal/css_parser/css_parser_test.go:2749:	expectPrintedLowerMangle(t, "@media not (2px > width > 1px) { a { color: red } }", "@media (min-width: 2px) or (max-width: 1px) {\n  a {\n    color: red;\n  }\n}\n", "")
internal/css_parser/css_parser_test.go:2750:	expectPrintedLowerMangle(t, "@media not (1px <= width <= 2px) { a { color: red } }", "@media not ((min-width: 1px) and (max-width: 2px)) {\n  a {\n    color: red;\n  }\n}\n", "")
internal/css_parser/css_parser_test.go:2751:	expectPrintedLowerMangle(t, "@media not (2px >= width >= 1px) { a { color: red } }", "@media not ((max-width: 2px) and (min-width: 1px)) {\n  a {\n    color: red;\n  }\n}\n", "")
internal/js_parser/js_parser_test.go:1195:	expectPrinted(t, "function* foo(){yield*\na}", "function* foo() {\n  yield* a;\n}\n")
internal/js_parser/js_parser_test.go:2264:	expectPrinted(t, "function *foo() { x = yield * y }", "function* foo() {\n  x = yield* y;\n}\n")
internal/js_parser/js_parser_test.go:2265:	expectPrinted(t, "function *foo() { (x = yield * y) }", "function* foo() {\n  x = yield* y;\n}\n")
internal/js_parser/js_parser_test.go:2266:	expectPrinted(t, "function *foo() { x = yield * \n y }", "function* foo() {\n  x = yield* y;\n}\n")
internal/js_parser/js_parser_lower_test.go:10:func TestLowerFunctionArgumentScope(t *testing.T) {
internal/js_parser/js_parser_lower_test.go:38:func TestLowerArrowFunction(t *testing.T) {
internal/js_parser/js_parser_lower_test.go:54:func TestLowerNullishCoalescing(t *testing.T) {
internal/js_parser/js_parser_lower_test.go:108:func TestLowerNullishCoalescingAssign(t *testing.T) {
internal/js_parser/js_parser_lower_test.go:165:func TestLowerLogicalAssign(t *testing.T) {
internal/js_parser/js_parser_lower_test.go:234:func TestLowerAsyncFunctions(t *testing.T) {
internal/js_parser/js_parser_lower_test.go:235:	// Lowered non-arrow functions with argument evaluations should merely use
internal/js_parser/js_parser_lower_test.go:250:func TestLowerClassSideEffectOrder(t *testing.T) {
internal/js_parser/js_parser_lower_test.go:281:func TestLowerClassInstance(t *testing.T) {
internal/js_parser/js_parser_lower_test.go:339:func TestLowerClassStatic(t *testing.T) {
internal/js_parser/js_parser_lower_test.go:453:func TestLowerClassStaticThis(t *testing.T) {
internal/js_parser/js_parser_lower_test.go:539:func TestLowerClassStaticBlocks(t *testing.T) {
internal/js_parser/js_parser_lower_test.go:551:func TestLowerOptionalChain(t *testing.T) {
internal/js_parser/js_parser_lower_test.go:720:func TestLowerOptionalCatchBinding(t *testing.T) {
internal/js_parser/js_parser_lower_test.go:725:func TestLowerBigInt(t *testing.T) {
internal/js_parser/js_parser_lower_test.go:780:func TestLowerExportStarAs(t *testing.T) {
internal/js_parser/js_parser_lower_test.go:785:func TestAsyncGeneratorFns(t *testing.T) {
internal/js_parser/js_parser_lower_test.go:802:	expectParseErrorWithUnsupportedFeatures(t, compat.AsyncGenerator, "async function* gen() {}", err)
internal/js_parser/js_parser_lower_test.go:803:	expectParseErrorWithUnsupportedFeatures(t, compat.AsyncGenerator, "(async function* () {});", err)
internal/js_parser/js_parser_lower_test.go:804:	expectParseErrorWithUnsupportedFeatures(t, compat.AsyncGenerator, "({ async *foo() {} });", err)
internal/js_parser/js_parser_lower_test.go:807:func TestForAwait(t *testing.T) {
internal/js_parser/js_parser_lower_test.go:812:	// This is ok because for-await can be lowered to await
internal/js_parser/js_parser_lower_test.go:813:	expectParseErrorWithUnsupportedFeatures(t, compat.ForAwait|compat.Generator, "async function gen() { for await (x of y) ; }", err)
internal/js_parser/js_parser_lower_test.go:815:	// This is ok because for-await can be lowered to yield
internal/js_parser/js_parser_lower_test.go:816:	expectParseErrorWithUnsupportedFeatures(t, compat.ForAwait|compat.AsyncAwait, "async function gen() { for await (x of y) ; }", err)
internal/js_parser/js_parser_lower_test.go:818:	// This is not ok because for-await can't be lowered
internal/js_parser/js_parser_lower_test.go:821:			"<stdin>: ERROR: Transforming for-await loops to the configured target environment is not supported yet\n"
internal/js_parser/js_parser_lower_test.go:822:	expectParseErrorWithUnsupportedFeatures(t, compat.ForAwait|compat.AsyncAwait|compat.Generator, "async function gen() { for await (x of y) ; }", err)
internal/js_parser/js_parser_lower_test.go:824:	// Can't use for-await at the top-level without top-level await
internal/js_parser/js_parser_lower_test.go:834:func TestLowerAutoAccessors(t *testing.T) {
shell
rg -n "AsyncGenerator|ForAwait|AsyncAwait|async generator|yield star|yieldStar" internal/compat internal/js_parser internal/bundler_tests -g '*.{go,txt}'
output
Chunk ID: 5ec642
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 2489
Output:
internal/compat/js_table.go:66:	AsyncAwait
internal/compat/js_table.go:67:	AsyncGenerator
internal/compat/js_table.go:87:	ForAwait
internal/compat/js_table.go:130:	"async-await":                       AsyncAwait,
internal/compat/js_table.go:131:	"async-generator":                   AsyncGenerator,
internal/compat/js_table.go:151:	"for-await":                         ForAwait,
internal/compat/js_table.go:235:	AsyncAwait: {
internal/compat/js_table.go:249:	AsyncGenerator: {
internal/compat/js_table.go:250:		// Note: The latest version of "Hermes" failed this test: Asynchronous Iterators: async generators
internal/compat/js_table.go:251:		// Note: The latest version of "IE" failed this test: Asynchronous Iterators: async generators
internal/compat/js_table.go:252:		// Note: The latest version of "Rhino" failed this test: Asynchronous Iterators: async generators
internal/compat/js_table.go:506:	ForAwait: {
internal/bundler_tests/bundler_lower_test.go:2343:func TestLowerForAwait2017(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2366:func TestLowerForAwait2015(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:2753:			UnsupportedJSFeatures: compat.AsyncAwait | compat.TopLevelAwait,
internal/bundler_tests/bundler_lower_test.go:2802:			UnsupportedJSFeatures: compat.Using | compat.AsyncAwait | compat.TopLevelAwait,
internal/bundler_tests/bundler_lower_test.go:2998:func TestLowerAsyncGenerator(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:3053:			UnsupportedJSFeatures: compat.AsyncGenerator,
internal/bundler_tests/bundler_lower_test.go:3058:func TestLowerAsyncGeneratorNoAwait(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:3113:			UnsupportedJSFeatures: compat.AsyncGenerator | compat.AsyncAwait,
internal/bundler_tests/bundler_lower_test.go:3148:func TestForAwaitWithOptionalCatchIssue4378(t *testing.T) {
internal/bundler_tests/bundler_lower_test.go:3161:			UnsupportedJSFeatures: compat.ForAwait,
internal/bundler_tests/snapshots/snapshots_lower.txt:20:TestForAwaitWithOptionalCatchIssue4378
internal/bundler_tests/snapshots/snapshots_lower.txt:1177:TestLowerAsyncGenerator
internal/bundler_tests/snapshots/snapshots_lower.txt:1185:      yield* __yieldStar(x);
internal/bundler_tests/snapshots/snapshots_lower.txt:1238:      yield* __yieldStar(x);
internal/bundler_tests/snapshots/snapshots_lower.txt:1291:      yield* __yieldStar(x);
internal/bundler_tests/snapshots/snapshots_lower.txt:1345:        yield* __yieldStar(x);
internal/bundler_tests/snapshots/snapshots_lower.txt:1400:        yield* __yieldStar(x);
internal/bundler_tests/snapshots/snapshots_lower.txt:1457:TestLowerAsyncGeneratorNoAwait
internal/bundler_tests/snapshots/snapshots_lower.txt:1465:      yield* __yieldStar(x);
internal/bundler_tests/snapshots/snapshots_lower.txt:1518:      yield* __yieldStar(x);
internal/bundler_tests/snapshots/snapshots_lower.txt:1571:      yield* __yieldStar(x);
internal/bundler_tests/snapshots/snapshots_lower.txt:1625:        yield* __yieldStar(x);
internal/bundler_tests/snapshots/snapshots_lower.txt:1680:        yield* __yieldStar(x);
internal/bundler_tests/snapshots/snapshots_lower.txt:2072:TestLowerForAwait2015
internal/bundler_tests/snapshots/snapshots_lower.txt:2180:TestLowerForAwait2017
internal/js_parser/js_parser_lower_test.go:785:func TestAsyncGeneratorFns(t *testing.T) {
internal/js_parser/js_parser_lower_test.go:787:	expectParseErrorWithUnsupportedFeatures(t, compat.AsyncAwait, "async function gen() {}", err)
internal/js_parser/js_parser_lower_test.go:788:	expectParseErrorWithUnsupportedFeatures(t, compat.AsyncAwait, "(async function () {});", err)
internal/js_parser/js_parser_lower_test.go:789:	expectParseErrorWithUnsupportedFeatures(t, compat.AsyncAwait, "({ async foo() {} });", err)
internal/js_parser/js_parser_lower_test.go:797:	expectParseErrorWithUnsupportedFeatures(t, compat.AsyncAwait|compat.Generator, "async function gen() {}", err)
internal/js_parser/js_parser_lower_test.go:798:	expectParseErrorWithUnsupportedFeatures(t, compat.AsyncAwait|compat.Generator, "(async function () {});", err)
internal/js_parser/js_parser_lower_test.go:799:	expectParseErrorWithUnsupportedFeatures(t, compat.AsyncAwait|compat.Generator, "({ async foo() {} });", err)
internal/js_parser/js_parser_lower_test.go:802:	expectParseErrorWithUnsupportedFeatures(t, compat.AsyncGenerator, "async function* gen() {}", err)
internal/js_parser/js_parser_lower_test.go:803:	expectParseErrorWithUnsupportedFeatures(t, compat.AsyncGenerator, "(async function* () {});", err)
internal/js_parser/js_parser_lower_test.go:804:	expectParseErrorWithUnsupportedFeatures(t, compat.AsyncGenerator, "({ async *foo() {} });", err)
internal/js_parser/js_parser_lower_test.go:807:func TestForAwait(t *testing.T) {
internal/js_parser/js_parser_lower_test.go:809:	expectParseErrorWithUnsupportedFeatures(t, compat.AsyncAwait, "async function gen() { for await (x of y) ; }", err)
internal/js_parser/js_parser_lower_test.go:813:	expectParseErrorWithUnsupportedFeatures(t, compat.ForAwait|compat.Generator, "async function gen() { for await (x of y) ; }", err)
internal/js_parser/js_parser_lower_test.go:816:	expectParseErrorWithUnsupportedFeatures(t, compat.ForAwait|compat.AsyncAwait, "async function gen() { for await (x of y) ; }", err)
internal/js_parser/js_parser_lower_test.go:822:	expectParseErrorWithUnsupportedFeatures(t, compat.ForAwait|compat.AsyncAwait|compat.Generator, "async function gen() { for await (x of y) ; }", err)
internal/js_parser/js_parser_lower.go:69:	case compat.AsyncAwait:
internal/js_parser/js_parser_lower.go:72:	case compat.AsyncGenerator:
internal/js_parser/js_parser_lower.go:73:		name = "async generator functions"
internal/js_parser/js_parser_lower.go:75:	case compat.ForAwait:
internal/js_parser/js_parser_lower.go:247:	feature := compat.AsyncAwait
internal/js_parser/js_parser_lower.go:249:		feature = compat.AsyncGenerator
internal/js_parser/js_parser_lower.go:343:	// Lower async functions and async generator functions
internal/js_parser/js_parser_lower.go:344:	if *isAsync && (p.options.unsupportedJSFeatures.Has(compat.AsyncAwait) || (isGenerator != nil && *isGenerator && p.options.unsupportedJSFeatures.Has(compat.AsyncGenerator))) {
internal/js_parser/js_parser_lower.go:1050:	// "await x" turns into "yield __await(x)" when lowering async generator functions
internal/js_parser/js_parser_lower.go:1051:	if p.fnOrArrowDataVisit.isGenerator && (p.options.unsupportedJSFeatures.Has(compat.AsyncAwait) || p.options.unsupportedJSFeatures.Has(compat.AsyncGenerator)) {
internal/js_parser/js_parser_lower.go:1061:	if p.options.unsupportedJSFeatures.Has(compat.AsyncAwait) {
internal/js_parser/js_parser_lower.go:1070:func (p *parser) lowerForAwaitLoop(loc logger.Loc, loop *js_ast.SForOf, stmts []js_ast.Stmt) []js_ast.Stmt {
internal/js_parser/js_parser_lower.go:1163:				IsLoweredForAwait: true,
internal/js_parser/js_parser_lower.go:1891:					p.options.unsupportedJSFeatures.Has(compat.AsyncAwait) ||
internal/js_parser/js_parser_lower.go:1892:					(p.options.unsupportedJSFeatures.Has(compat.AsyncGenerator) && p.fnOrArrowDataVisit.isGenerator)))) {
internal/js_parser/js_parser.go:3023:					if !isArrowFn && (flags&exprFlagForAwaitLoopInit) == 0 && p.lexer.Raw() == "of" {
internal/js_parser/js_parser.go:3489:	exprFlagForAwaitLoopInit
internal/js_parser/js_parser.go:4995:		if opts.isForAwaitLoopInit {
internal/js_parser/js_parser.go:4996:			flags |= exprFlagForAwaitLoopInit
internal/js_parser/js_parser.go:7044:	isForAwaitLoopInit      bool
internal/js_parser/js_parser.go:7750:				if !didGenerateError && p.options.unsupportedJSFeatures.Has(compat.AsyncAwait) && p.options.unsupportedJSFeatures.Has(compat.Generator) {
internal/js_parser/js_parser.go:7754:					p.markSyntaxFeature(compat.ForAwait, awaitRange)
internal/js_parser/js_parser.go:7797:				isForAwaitLoopInit: awaitRange.Len > 0,
internal/js_parser/js_parser.go:10649:			if loop, ok := try.Block.Stmts[0].Data.(*js_ast.SFor); ok && loop.IsLoweredForAwait {
internal/js_parser/js_parser.go:10832:			// Returning undefined is implicit except when inside an async generator
internal/js_parser/js_parser.go:11061:				} else if p.options.unsupportedJSFeatures.Has(compat.Using) || p.options.unsupportedJSFeatures.Has(compat.AsyncAwait) ||
internal/js_parser/js_parser.go:11062:					(p.options.unsupportedJSFeatures.Has(compat.AsyncGenerator) && p.fnOrArrowDataVisit.isGenerator) {
internal/js_parser/js_parser.go:11072:		// Lower "for await" if it's unsupported if it's in a lowered async generator
internal/js_parser/js_parser.go:11073:		if s.Await.Len > 0 && (p.options.unsupportedJSFeatures.Has(compat.ForAwait) ||
internal/js_parser/js_parser.go:11074:			(p.options.unsupportedJSFeatures.Has(compat.AsyncGenerator) && p.fnOrArrowDataVisit.isGenerator)) {
internal/js_parser/js_parser.go:11075:			return p.lowerForAwaitLoop(stmt.Loc, s, stmts)
internal/js_parser/js_parser.go:14765:		// "yield* x" turns into "yield* __yieldStar(x)" when lowering async generator functions
internal/js_parser/js_parser.go:14766:		if e.IsStar && p.options.unsupportedJSFeatures.Has(compat.AsyncGenerator) && p.fnOrArrowDataVisit.isGenerator {
internal/js_parser/js_parser.go:14767:			e.ValueOrNil = p.callRuntime(expr.Loc, "__yieldStar", []js_ast.Expr{e.ValueOrNil})
internal/js_parser/js_parser.go:14888:				if property.Kind == js_ast.PropertyMethod && p.options.unsupportedJSFeatures.Has(compat.AsyncAwait) {
internal/js_parser/js_parser.go:15795:		asyncArrowNeedsToBeLowered := e.IsAsync && p.options.unsupportedJSFeatures.Has(compat.AsyncAwait)
internal/js_parser/js_parser.go:17002:		isInsideUnsupportedAsyncArrow := p.fnOnlyDataVisit.isInsideAsyncArrowFn && p.options.unsupportedJSFeatures.Has(compat.AsyncAwait)
internal/js_parser/js_parser.go:17143:		shouldLowerSuperPropertyAccess: (fn.IsAsync && p.options.unsupportedJSFeatures.Has(compat.AsyncAwait)) || opts.isLoweredPrivateMethod,
The current `__asyncGenerator` resumes every iterator method immediately, so concurrent `next`/`throw`/`return` calls can re-enter the lowered generator out of order. I’m going to build a small Node comparison harness against the emitted helper shape so I can pin the native ordering before editing.
shell
sed -n '2980,3130p' internal/bundler_tests/bundler_lower_test.go
output
Chunk ID: 2a6435
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 949
Output:
		files: map[string]string{
			"/entry.ts": `
				namespace ns {
					export let a = b
					using c = d
					export let e = f
				}
			`,
		},
		entryPaths: []string{"/entry.ts"},
		options: config.Options{
			Mode:                  config.ModePassThrough,
			AbsOutputDir:          "/out",
			UnsupportedJSFeatures: compat.Using,
		},
	})
}

func TestLowerAsyncGenerator(t *testing.T) {
	lower_suite.expectBundled(t, bundled{
		files: map[string]string{
			"/entry.ts": `
				async function* foo() {
					yield
					yield x
					yield *x
					await using x = await y
					for await (let x of y) {}
					for await (await using x of y) {}
				}
				foo = async function* () {
					yield
					yield x
					yield *x
					await using x = await y
					for await (let x of y) {}
					for await (await using x of y) {}
				}
				foo = { async *bar () {
					yield
					yield x
					yield *x
					await using x = await y
					for await (let x of y) {}
					for await (await using x of y) {}
				} }
				class Foo { async *bar () {
					yield
					yield x
					yield *x
					await using x = await y
					for await (let x of y) {}
					for await (await using x of y) {}
				} }
				Foo = class { async *bar () {
					yield
					yield x
					yield *x
					await using x = await y
					for await (let x of y) {}
					for await (await using x of y) {}
				} }
				async function bar() {
					await using x = await y
					for await (let x of y) {}
					for await (await using x of y) {}
				}
			`,
		},
		entryPaths: []string{"/entry.ts"},
		options: config.Options{
			Mode:                  config.ModePassThrough,
			AbsOutputDir:          "/out",
			UnsupportedJSFeatures: compat.AsyncGenerator,
		},
	})
}

func TestLowerAsyncGeneratorNoAwait(t *testing.T) {
	lower_suite.expectBundled(t, bundled{
		files: map[string]string{
			"/entry.ts": `
				async function* foo() {
					yield
					yield x
					yield *x
					await using x = await y
					for await (let x of y) {}
					for await (await using x of y) {}
				}
				foo = async function* () {
					yield
					yield x
					yield *x
					await using x = await y
					for await (let x of y) {}
					for await (await using x of y) {}
				}
				foo = { async *bar () {
					yield
					yield x
					yield *x
					await using x = await y
					for await (let x of y) {}
					for await (await using x of y) {}
				} }
				class Foo { async *bar () {
					yield
					yield x
					yield *x
					await using x = await y
					for await (let x of y) {}
					for await (await using x of y) {}
				} }
				Foo = class { async *bar () {
					yield
					yield x
					yield *x
					await using x = await y
					for await (let x of y) {}
					for await (await using x of y) {}
				} }
				async function bar() {
					await using x = await y
					for await (let x of y) {}
					for await (await using x of y) {}
				}
			`,
		},
		entryPaths: []string{"/entry.ts"},
		options: config.Options{
			Mode:                  config.ModePassThrough,
			AbsOutputDir:          "/out",
			UnsupportedJSFeatures: compat.AsyncGenerator | compat.AsyncAwait,
		},
	})
}

// https://[code-host]/evanw/esbuild/issues/3768
func TestJavaScriptDecoratorsBundleIssue3768(t *testing.T) {
	lower_suite.expectBundled(t, bundled{
		files: map[string]string{
			"/base-instance-method.js":   `class Foo { @dec foo() { return Foo } }`,
			"/base-instance-field.js":    `class Foo { @dec foo = Foo }`,
			"/base-instance-accessor.js": `class Foo { @dec accessor foo = Foo }`,

			"/base-static-method.js":   `class Foo { @dec static foo() { return Foo } }`,
			"/base-static-field.js":    `class Foo { @dec static foo = Foo }`,
			"/base-static-accessor.js": `class Foo { @dec static accessor foo = Foo }`,

			"/derived-instance-method.js":   `class Foo extends Bar { @dec foo() { return Foo } }`,
shell
rg -n "runtime" internal/*_tests internal/runtime -g '*_test.go'
output
Chunk ID: 3eaf7b
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 280
Output:
internal/runtime/runtime_test.go:1:package runtime_test
internal/runtime/runtime_test.go:10:	"[code-host]/evanw/esbuild/internal/runtime"
internal/runtime/runtime_test.go:16:			source := runtime.Source(feature)
internal/runtime/runtime_test.go:25:				msgs := "Internal error: failed to parse runtime:\n"
internal/bundler_tests/bundler_dce_test.go:2348:// Calls to the runtime "__publicField" function are not considered side effects
internal/bundler_tests/bundler_tsconfig_test.go:649:					"react/jsx-runtime": true,
internal/bundler_tests/bundler_tsconfig_test.go:677:					"notreact/jsx-runtime": true,
internal/bundler_tests/bundler_tsconfig_test.go:704:					"react/jsx-dev-runtime": true,
internal/bundler_tests/bundler_tsconfig_test.go:734:					"react/jsx-dev-runtime": true,
internal/bundler_tests/bundler_default_test.go:562:					"react/jsx-runtime": true,
internal/bundler_tests/bundler_default_test.go:590:					"react/jsx-runtime": true,
internal/bundler_tests/bundler_default_test.go:613:					"react/jsx-runtime": true,
internal/bundler_tests/bundler_default_test.go:8944:						"react/jsx-dev-runtime": true,
shell
rg --files | rg '(^cmd/esbuild|api|snapshots|scripts|js-api|package.json)$'
output
Chunk ID: e58dd2
Wall time: 0.0000 seconds
Process exited with code 1
Original token count: 0
Output:
shell
sed -n '1,120p' internal/runtime/runtime_test.go
output
Chunk ID: 76bb5c
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 228
Output:
package runtime_test

import (
	"testing"

	"[code-host]/evanw/esbuild/internal/compat"
	"[code-host]/evanw/esbuild/internal/config"
	"[code-host]/evanw/esbuild/internal/js_parser"
	"[code-host]/evanw/esbuild/internal/logger"
	"[code-host]/evanw/esbuild/internal/runtime"
)

func TestUnsupportedFeatures(t *testing.T) {
	for key, feature := range compat.StringToJSFeature {
		t.Run(key, func(t *testing.T) {
			source := runtime.Source(feature)
			log := logger.NewDeferLog(logger.DeferLogAll, nil)

			js_parser.Parse(log, source, js_parser.OptionsFromConfig(&config.Options{
				UnsupportedJSFeatures: feature,
				TreeShaking:           true,
			}))

			if log.HasErrors() {
				msgs := "Internal error: failed to parse runtime:\n"
				for _, msg := range log.Done() {
					msgs += msg.String(logger.OutputOptions{IncludeSource: true}, logger.TerminalInfo{})
				}
				t.Fatal(msgs[:len(msgs)-1])
			}
		})
	}
}
shell
find . -maxdepth 2 -type f | sed 's#^./##' | sort | head -100
output
Chunk ID: 8b9f14
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 12
Output:
LICENSE.md
esbuild
go.mod
go.sum
version.txt
shell
ls -la
output
Chunk ID: 5b7b5c
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 135
Output:
total 14368
drwxr-xr-x  1 root root     4096 Jun 21 17:04 .
drwxr-xr-x  1 root root     4096 Jun 21 17:24 ..
-rw-r--r--  1 root root     1069 Jun 10 04:32 LICENSE.md
drwxr-xr-x  3 root root     4096 Jun 10 04:32 cmd
-rwxr-xr-x  1 root root 14674007 Jun 21 17:04 esbuild
-rw-r--r--  1 root root      428 Jun 10 04:32 go.mod
-rw-r--r--  1 root root      207 Jun 10 04:32 go.sum
drwxr-xr-x 29 root root     4096 Jun 10 04:32 internal
drwxr-xr-x  4 root root     4096 Jun 10 04:32 pkg
-rw-r--r--  1 root root        7 Jun 10 04:32 version.txt
I’m checking one subtle part of the existing `__yieldStar` protocol now. It uses a two-step handoff with `__await(..., 1)`, so the queue has to sequence outer resumes without breaking that handoff.
shell
node - <<'EOF'
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for('Symbol.' + name)
var __typeError = msg => { throw TypeError(msg) }
var __await = function (promise, isYieldStar) { this[0] = promise; this[1] = isYieldStar }
var __asyncGenerator = (__this, __arguments, generator) => {
  var resume = (k, v, yes, no) => {
    try {
      var x = generator[k](v), isAwait = (v = x.value) instanceof __await, done = x.done
      Promise.resolve(isAwait ? v[0] : v)
        .then(y => isAwait
          ? resume(k === 'return' ? k : 'next', v[1] ? { done: y.done, value: y.value } : y, yes, no)
          : yes({ value: y, done }))
        .catch(e => resume('throw', e, yes, no))
    } catch (e) { no(e) }
  }, method = k => it[k] = x => new Promise((yes, no) => resume(k, x, yes, no)), it = {}
  return generator = generator.apply(__this, __arguments), it[Symbol.asyncIterator] = () => it, method('next'), method('throw'), method('return'), it
}
var __yieldStar = value => {
  var obj = value[Symbol.asyncIterator], isAwait = false, method, it = {}
  if (obj == null) { obj = value[Symbol.iterator](); method = k => it[k] = x => obj[k](x) }
  else {
    obj = obj.call(value)
    method = k => it[k] = v => {
      console.log('ys method', k, 'isAwait', isAwait, 'v', v)
      if (isAwait) { isAwait = false; if (k === 'throw') throw v; return v }
      isAwait = true
      return { done: false, value: new __await(new Promise(resolve => { var x = obj[k](v); console.log('inner result promise?', x); if (!(x instanceof Object)) __typeError('Object expected'); resolve(x) }), 1) }
    }
  }
  return it[Symbol.iterator] = () => it, method('next'), 'throw' in obj ? method('throw') : it.throw = x => { throw x }, 'return' in obj && method('return'), it
}
async function* inner(){ let v = yield 'a'; console.log('inner got', v); yield 'b' }
function outer(){ return __asyncGenerator(this, null, function*(){ yield* __yieldStar(inner()) }) }
(async()=>{
 const it=outer();
 console.log(await it.next());
 console.log(await it.next('sent'));
 console.log(await it.next());
})().catch(e=>console.log('ERR', e && e.stack || e))
EOF
output
Chunk ID: c6f9af
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 139
Output:
ys method next isAwait false v undefined
inner result promise? Promise { <pending> }
ys method next isAwait true v { done: false, value: 'a' }
{ value: 'a', done: false }
ys method next isAwait false v sent
inner got sent
inner result promise? Promise { <pending> }
ys method next isAwait true v { done: false, value: 'b' }
{ value: 'b', done: false }
ys method next isAwait false v undefined
inner result promise? Promise { { value: undefined, done: true } }
ys method next isAwait true v { done: true, value: undefined }
{ value: undefined, done: true }
The handoff is as expected: `__yieldStar` consumes an internal iterator result on the second step, then later user-supplied `next(value)` reaches the inner suspended yield. The runtime queue needs to serialize those internal continuation steps together with external calls.
shell
node - <<'EOF'
async function run(label, outer) {
  let log=[]; const rec=x=>log.push(x); const it=outer(rec);
  let p1=it.next(); rec('after p1'); let p2=it.return('done'); rec('after p2');
  p1.then(x=>rec('p1 '+JSON.stringify(x)), e=>rec('p1 err '+e));
  p2.then(x=>rec('p2 '+JSON.stringify(x)), e=>rec('p2 err '+e));
  await Promise.allSettled([p1,p2]);
  console.log(label, JSON.stringify(log));
}
async function* inner(rec){ try { rec('inner start'); yield await Promise.resolve('value'); rec('after yield'); } finally { rec('finally'); yield 'cleanup'; rec('after cleanup'); } }
async function* nativeOuter(rec){ rec('outer start'); yield* inner(rec); rec('outer after'); }
run('native', nativeOuter).catch(console.error)
EOF
output
Chunk ID: 3874a1
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 39
Output:
native ["outer start","inner start","after p1","after p2","p1 {\"value\":\"value\",\"done\":false}","finally","p2 {\"value\":\"cleanup\",\"done\":false}"]
A native check confirms the important ordering from the prompt: for `next(); return()` through `yield*`, the first `next` result settles before the inner `finally` side effect. Now I’m going to reproduce that against lowered code and patch the helper around that failure.
shell
node - <<'EOF'
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for('Symbol.' + name)
var __typeError = msg => { throw TypeError(msg) }
var __await = function (promise, isYieldStar) { this[0] = promise; this[1] = isYieldStar }
var __asyncGenerator = (__this, __arguments, generator) => {
  var resume = (k, v, yes, no) => {
    try {
      var x = generator[k](v), isAwait = (v = x.value) instanceof __await, done = x.done
      Promise.resolve(isAwait ? v[0] : v)
        .then(y => isAwait
          ? resume(k === 'return' ? k : 'next', v[1] ? { done: y.done, value: y.value } : y, yes, no)
          : yes({ value: y, done }))
        .catch(e => resume('throw', e, yes, no))
    } catch (e) { no(e) }
  }, method = k => it[k] = x => new Promise((yes, no) => resume(k, x, yes, no)), it = {}
  return generator = generator.apply(__this, __arguments), it[Symbol.asyncIterator] = () => it, method('next'), method('throw'), method('return'), it
}
var __yieldStar = value => {
  var obj = value[Symbol.asyncIterator], isAwait = false, method, it = {}
  if (obj == null) { obj = value[Symbol.iterator](); method = k => it[k] = x => obj[k](x) }
  else { obj = obj.call(value); method = k => it[k] = v => { if (isAwait) { isAwait = false; if (k === 'throw') throw v; return v } isAwait = true; return { done: false, value: new __await(new Promise(resolve => { var x = obj[k](v); if (!(x instanceof Object)) __typeError('Object expected'); resolve(x) }), 1) } } }
  return it[Symbol.iterator] = () => it, method('next'), 'throw' in obj ? method('throw') : it.throw = x => { throw x }, 'return' in obj && method('return'), it
}
function inner(rec){ return __asyncGenerator(this, null, function*(){ try { rec('inner start'); yield new __await(Promise.resolve('value')); yield 'value'; rec('after yield'); } finally { rec('finally'); yield 'cleanup'; rec('after cleanup'); } }) }
function outer(rec){ return __asyncGenerator(this, null, function*(){ rec('outer start'); yield* __yieldStar(inner(rec)); rec('outer after'); }) }
(async()=>{ let log=[]; const rec=x=>log.push(x); const it=outer(rec); let p1=it.next(); rec('after p1'); let p2=it.return('done'); rec('after p2'); p1.then(x=>rec('p1 '+JSON.stringify(x)), e=>rec('p1 err '+e)); p2.then(x=>rec('p2 '+JSON.stringify(x)), e=>rec('p2 err '+e)); await Promise.allSettled([p1,p2]); console.log(JSON.stringify(log)); })().catch(console.error)
EOF
output
Chunk ID: b38211
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 33
Output:
["outer start","inner start","after p1","after p2","p2 err TypeError: Iterator result done is not an object","p1 {\"done\":true}"]
My first hand-written transform was too rough around `yield await`. I’m switching to actual esbuild output for the behavioral harness so the failure matches the project’s lowering exactly.
shell
printf '%s
' 'async function* inner(rec){ try { rec("inner start"); yield await Promise.resolve("value"); rec("after yield"); } finally { rec("finally"); yield "cleanup"; rec("after cleanup"); } } async function* outer(rec){ rec("outer start"); yield* inner(rec); rec("outer after"); }' | ./esbuild --loader=js --target=es2017 --format=cjs
output
Chunk ID: a36c3b
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 579
Output:
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
var __typeError = (msg) => {
  throw TypeError(msg);
};
var __await = function(promise, isYieldStar) {
  this[0] = promise;
  this[1] = isYieldStar;
};
var __asyncGenerator = (__this, __arguments, generator) => {
  var resume = (k, v, yes, no) => {
    try {
      var x = generator[k](v), isAwait = (v = x.value) instanceof __await, done = x.done;
      Promise.resolve(isAwait ? v[0] : v).then((y) => isAwait ? resume(k === "return" ? k : "next", v[1] ? { done: y.done, value: y.value } : y, yes, no) : yes({ value: y, done })).catch((e) => resume("throw", e, yes, no));
    } catch (e) {
      no(e);
    }
  }, method = (k) => it[k] = (x) => new Promise((yes, no) => resume(k, x, yes, no)), it = {};
  return generator = generator.apply(__this, __arguments), it[__knownSymbol("asyncIterator")] = () => it, method("next"), method("throw"), method("return"), it;
};
var __yieldStar = (value) => {
  var obj = value[__knownSymbol("asyncIterator")], isAwait = false, method, it = {};
  if (obj == null) {
    obj = value[__knownSymbol("iterator")]();
    method = (k) => it[k] = (x) => obj[k](x);
  } else {
    obj = obj.call(value);
    method = (k) => it[k] = (v) => {
      if (isAwait) {
        isAwait = false;
        if (k === "throw") throw v;
        return v;
      }
      isAwait = true;
      return {
        done: false,
        value: new __await(new Promise((resolve) => {
          var x = obj[k](v);
          if (!(x instanceof Object)) __typeError("Object expected");
          resolve(x);
        }), 1)
      };
    };
  }
  return it[__knownSymbol("iterator")] = () => it, method("next"), "throw" in obj ? method("throw") : it.throw = (x) => {
    throw x;
  }, "return" in obj && method("return"), it;
};
function inner(rec) {
  return __asyncGenerator(this, null, function* () {
    try {
      rec("inner start");
      yield yield new __await(Promise.resolve("value"));
      rec("after yield");
    } finally {
      rec("finally");
      yield "cleanup";
      rec("after cleanup");
    }
  });
}
function outer(rec) {
  return __asyncGenerator(this, null, function* () {
    rec("outer start");
    yield* __yieldStar(inner(rec));
    rec("outer after");
  });
}
shell
node - <<'EOF'
async function* gen(log){ log.push('start'); let x=yield await Promise.resolve('a'); log.push('got '+x); yield 'b'; }
(async()=>{let log=[]; let it=gen(log); let p1=it.next(); log.push('after p1'); let p2=it.next('x'); log.push('after p2'); p1.then(r=>log.push('p1 '+JSON.stringify(r))); p2.then(r=>log.push('p2 '+JSON.stringify(r))); await Promise.all([p1,p2]); console.log(JSON.stringify(log));})();
EOF
output
Chunk ID: cecfc4
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 29
Output:
["start","after p1","after p2","got x","p1 {\"value\":\"a\",\"done\":false}","p2 {\"value\":\"b\",\"done\":false}"]
shell
node - <<'EOF'
async function* gen(log){ try { log.push('start'); let x=yield await Promise.resolve('a'); log.push('got '+x); } catch(e) { log.push('catch '+e); yield 'recovery'; } finally { log.push('finally'); } }
(async()=>{let log=[]; let it=gen(log); let p1=it.next(); log.push('after p1'); let p2=it.throw('boom'); log.push('after p2'); p1.then(r=>log.push('p1 '+JSON.stringify(r)),e=>log.push('p1err '+e)); p2.then(r=>log.push('p2 '+JSON.stringify(r)),e=>log.push('p2err '+e)); await Promise.allSettled([p1,p2]); console.log(JSON.stringify(log));})();
EOF
output
Chunk ID: 9d1cd1
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 32
Output:
["start","after p1","after p2","catch boom","p1 {\"value\":\"a\",\"done\":false}","p2 {\"value\":\"recovery\",\"done\":false}"]
Native scheduling is asymmetric in practice: queued `next` and `throw` resume as soon as the generator is suspended at a yield, before user `.then` handlers for the previous `next`; queued `return` waits until after the previous yield’s promise reactions have had a chance to run. I’m shaping the helper around that distinction.
shell
node - <<'EOF'
async function* gen(log){ try { log.push('start'); let x=yield await Promise.resolve('a'); log.push('got '+x); } finally { log.push('finally'); yield 'cleanup'; } }
(async()=>{let log=[]; let it=gen(log); let p1=it.next(); log.push('after p1'); let p2=it.return('done'); log.push('after p2'); p1.then(r=>log.push('p1 '+JSON.stringify(r)),e=>log.push('p1err '+e)); p2.then(r=>log.push('p2 '+JSON.stringify(r)),e=>log.push('p2err '+e)); await Promise.allSettled([p1,p2]); console.log(JSON.stringify(log));})();
EOF
output
Chunk ID: 79a37e
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 31
Output:
["start","after p1","after p2","p1 {\"value\":\"a\",\"done\":false}","finally","p2 {\"value\":\"cleanup\",\"done\":false}"]
The viable structure is now clear: each iterator method gets its own promise, and later calls chain from the previous method’s promise. Since those internal chain reactions are registered when the method is called, native microtask order falls out for queued `next`/`throw`; `return` needs one explicit additional hop.
shell
node - <<'EOF'
async function* gen(log){ log.push('start'); let x=yield await Promise.resolve('a'); log.push('got '+x); yield 'b'; }
(async()=>{let log=[]; let it=gen(log); let p1=it.next(); log.push('after p1'); p1.then(r=>log.push('p1 '+JSON.stringify(r))); let p2=it.next('x'); log.push('after p2'); p2.then(r=>log.push('p2 '+JSON.stringify(r))); await Promise.all([p1,p2]); console.log(JSON.stringify(log));})();
EOF
output
Chunk ID: 486b6c
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 29
Output:
["start","after p1","after p2","got x","p1 {\"value\":\"a\",\"done\":false}","p2 {\"value\":\"b\",\"done\":false}"]
shell
node - <<'EOF'
async function* gen(log){ try { log.push('start'); yield await Promise.resolve('a'); } finally { log.push('finally'); yield 'cleanup'; log.push('after cleanup'); } log.push('after try'); yield 'z'; }
(async()=>{let log=[]; let it=gen(log); let p1=it.next(); let p2=it.return('done'); let p3=it.next('after'); p1.then(r=>log.push('p1 '+JSON.stringify(r))); p2.then(r=>log.push('p2 '+JSON.stringify(r))); p3.then(r=>log.push('p3 '+JSON.stringify(r))); await Promise.allSettled([p1,p2,p3]); console.log(JSON.stringify(log));})();
EOF
output
Chunk ID: 592601
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 40
Output:
["start","p1 {\"value\":\"a\",\"done\":false}","finally","after cleanup","p2 {\"value\":\"cleanup\",\"done\":false}","p3 {\"value\":\"done\",\"done\":true}"]
shell
node - <<'EOF'
async function* inner(log){ try{ log.push('inner start'); yield await Promise.resolve('a'); } finally { log.push('finally'); yield 'cleanup'; log.push('after cleanup'); } }
async function* outer(log){ yield* inner(log); log.push('outer after'); }
(async()=>{let log=[]; let it=outer(log); console.log(await it.next(), log); console.log(await it.return('done'), log); console.log(await it.next('x'), log);})();
EOF
output
Chunk ID: acb477
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 51
Output:
{ value: 'a', done: false } [ 'inner start' ]
{ value: 'cleanup', done: false } [ 'inner start', 'finally' ]
{ value: undefined, done: true } [ 'inner start', 'finally', 'after cleanup', 'outer after' ]
shell
tmp=$(mktemp -d); cat > $tmp/in.js <<'EOF'
async function* inner(log){ try{ log.push('inner start'); yield await Promise.resolve('a'); } finally { log.push('finally'); yield 'cleanup'; log.push('after cleanup'); } }
async function* outer(log){ yield* inner(log); log.push('outer after'); }
(async()=>{let log=[]; let it=outer(log); console.log(JSON.stringify([await it.next(), log.slice()])); console.log(JSON.stringify([await it.return('done'), log.slice()])); console.log(JSON.stringify([await it.next('x'), log.slice()]));})();
EOF
./esbuild $tmp/in.js --bundle --target=es2017 --format=cjs > $tmp/out.js
node $tmp/out.js
output
Chunk ID: 85a628
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 45
Output:
[{"value":"a","done":false},["inner start"]]
[{"value":"cleanup","done":false},["inner start","finally"]]
[{"done":true},["inner start","finally","after cleanup","outer after"]]
shell
node - <<'EOF'
async function* gen(log){log.push('start'); throw 'err'}
let log=[]; let it=gen(log); let p1=it.next(); log.push('after p1'); let p2=it.next(); log.push('after p2'); p1.catch(e=>log.push('p1 '+e)); p2.then(r=>log.push('p2 '+JSON.stringify(r)),e=>log.push('p2err '+e)); Promise.allSettled([p1,p2]).then(()=>console.log(JSON.stringify(log)))
EOF
output
Chunk ID: 157d26
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 16
Output:
["start","after p1","after p2","p1 err","p2 {\"done\":true}"]
I’m going to patch only the runtime helper, keeping the helper exports and lowering entry points intact. The queue will use an internal promise so user-attached `.then` handlers cannot accidentally reorder the generator’s own request queue.
apply_patch
*** Begin Patch
*** Update File: /app/internal/runtime/runtime.go
@@
 		export var __asyncGenerator = (__this, __arguments, generator) => {
 			var resume = (k, v, yes, no) => {
 				try {
 					var x = generator[k](v), isAwait = (v = x.value) instanceof __await, done = x.done
 					Promise.resolve(isAwait ? v[0] : v)
@@
 				} catch (e) {
 					no(e)
 				}
-			}, method = k => it[k] = x => new Promise((yes, no) => resume(k, x, yes, no)), it = {}
+			}, method = k => it[k] = x => {
+				var run
+				x = new Promise((yes, no) => {
+					run = () => {
+						var done
+						var queue = new Promise(resolve => done = resolve)
+						resume(k, x, y => (done(), yes(y)), e => (done(), no(e)))
+						queue.then(() => --pending || (tail = 0))
+						return queue
+					}
+					pending++
+					tail = tail ? tail.then(k === 'return' ? () => Promise.resolve().then(run) : run) : run()
+				})
+				return x
+			}, it = {}, tail, pending = 0
 			return generator = generator.apply(__this, __arguments),
 				it[__knownSymbol('asyncIterator')] = () => it,
 				method('next'),
 				method('throw'),
*** End Patch


Exit code: 0
Wall time: 0 seconds
Output:
Success. Updated the following files:
M /app/internal/runtime/runtime.go
I spotted a capture issue in the first edit: the method argument and returned promise need separate bindings, otherwise the resumed value would be wrong. I’m tightening that before running behavior checks.
apply_patch
*** Begin Patch
*** Update File: /app/internal/runtime/runtime.go
@@
-			}, method = k => it[k] = x => {
-				var run
-				x = new Promise((yes, no) => {
+			}, method = k => it[k] = x => {
+				var run, value = x
+				x = new Promise((yes, no) => {
 					run = () => {
 						var done
 						var queue = new Promise(resolve => done = resolve)
-						resume(k, x, y => (done(), yes(y)), e => (done(), no(e)))
+						resume(k, value, y => (done(), yes(y)), e => (done(), no(e)))
 						queue.then(() => --pending || (tail = 0))
 						return queue
 					}
*** End Patch


Exit code: 0
Wall time: 0 seconds
Output:
Success. Updated the following files:
M /app/internal/runtime/runtime.go
The helper now queues method calls through an internal promise chain and keeps the first call synchronous. I’m going to run the existing runtime parse tests and then compare lowered output against native Node traces for the concurrent cases.
shell
go test ./internal/runtime
output
Chunk ID: c10667
Wall time: 3.4668 seconds
Process exited with code 0
Original token count: 14
Output:
ok  	[code-host]/evanw/esbuild/internal/runtime	0.076s
shell
go test ./internal/bundler_tests -run 'TestLowerAsyncGenerator|TestLowerForAwait2017|TestLowerForAwait2015'
output
Chunk ID: da6fe0
Wall time: 3.8086 seconds
Process exited with code 1
Original token count: 1313
Output:
PASS
snapshots/snapshots_lower.txt
    No test found for snapshot TestLowerPrivateSuperES2021
    No test found for snapshot TestTSLowerPrivateFieldOptionalChain2015NoBundle
    No test found for snapshot TestLowerAsync2017NoBundle
    No test found for snapshot TestLowerPrivateFieldAssignmentsNextNoBundle
    No test found for snapshot TestLowerStaticAsyncArrowSuperSetterES2016
    No test found for snapshot TestLowerUsingUnsupportedUsingAndAsync
    No test found for snapshot TestLowerPrivateClassBrandCheckSupported
    No test found for snapshot TestLowerPrivateFieldOptionalChain2020NoBundle
    No test found for snapshot TestTSLowerClassField2020NoBundle
    No test found for snapshot TestJavaScriptAutoAccessorESNext
    No test found for snapshot TestLowerPrivateClassExpr2020NoBundle
    No test found for snapshot TestLowerPrivateClassMethodOrder
    No test found for snapshot TestJavaScriptAutoAccessorES2022
    No test found for snapshot TestLowerNestedFunctionDirectEval
    No test found for snapshot TestLowerPrivateClassBrandCheckUnsupported
    No test found for snapshot TestLowerPrivateMethodWithModifiers2020
    No test found for snapshot TestLowerStaticAsyncArrowSuperES2016
    No test found for snapshot TestLowerStrictModeSyntax
    No test found for snapshot TestTSLowerClassPrivateFieldNextNoBundle
    No test found for snapshot TestLowerPrivateFieldAssignments2019NoBundle
    No test found for snapshot TestLowerNullishCoalescingAssignmentIssue1493
    No test found for snapshot TestForAwaitWithOptionalCatchIssue4378
    No test found for snapshot TestLowerAsyncArrowSuperES2016
    No test found for snapshot TestLowerAsyncThis2016CommonJS
    No test found for snapshot TestLowerPrivateClassStaticAccessorOrder
    No test found for snapshot TestLowerPrivateClassStaticMethodOrder
    No test found for snapshot TestTSLowerClassFieldStrictTsconfigJson2020
    No test found for snapshot TestLowerClassFieldStrictTsconfigJson2020
    No test found for snapshot TestLowerPrivateFieldOptionalChainNextNoBundle
    No test found for snapshot TestStaticClassBlockES2021
    No test found for snapshot TestTSLowerObjectRest2017NoBundle
    No test found for snapshot TestJavaScriptDecoratorsBundleIssue3768
    No test found for snapshot TestLowerOptionalCatchNameCollisionNoBundle
    No test found for snapshot TestLowerUsing
    No test found for snapshot TestTSLowerPrivateStaticMembers2015NoBundle
    No test found for snapshot TestLowerAsync2016NoBundle
    No test found for snapshot TestLowerExponentiationOperatorNoBundle
    No test found for snapshot TestLowerPrivateClassFieldOrder
    No test found for snapshot TestLowerPrivateClassFieldStaticIssue1424
    No test found for snapshot TestJavaScriptDecoratorsESNext
    No test found for snapshot TestLowerAsyncSuperES2017NoBundle
    No test found for snapshot TestLowerPrivateMethod2020
    No test found for snapshot TestLowerPrivateSuperStaticBundleIssue2158
    No test found for snapshot TestJavaScriptAutoAccessorES2021
    No test found for snapshot TestLowerPrivateGetterSetterNext
    No test found for snapshot TestLowerRegExpNameCollision
    No test found for snapshot TestTSLowerObjectRest2018NoBundle
    No test found for snapshot TestClassSuperThisIssue242NoBundle
    No test found for snapshot TestLowerPrivateFieldAssignments2015NoBundle
    No test found for snapshot TestLowerPrivateGetterSetter2019
    No test found for snapshot TestLowerPrivateGetterSetter2020
    No test found for snapshot TestLowerPrivateMethodNext
    No test found for snapshot TestLowerStaticSuperES2021NoBundle
    No test found for snapshot TestLowerPrivateMethod2019
    No test found for snapshot TestLowerStaticSuperES2016NoBundle
    No test found for snapshot TestLowerTemplateObject
    No test found for snapshot TestLowerPrivateFieldAssignments2020NoBundle
    No test found for snapshot TestLowerExportStarAsNameCollisionNoBundle
    No test found for snapshot TestLowerPrivateClassAccessorOrder
    No test found for snapshot TestLowerUsingUnsupportedAsync
    No test found for snapshot TestStaticClassBlockESNext
    No test found for snapshot TestLowerAsyncThis2016ES6
    No test found for snapshot TestLowerPrivateClassStaticFieldOrder
    No test found for snapshot TestLowerPrivateFieldOptionalChain2019NoBundle
    No test found for snapshot TestLowerPrivateGetterSetter2015
    No test found for snapshot TestLowerStaticAsyncSuperES2016NoBundle
    No test found for snapshot TestLowerStaticAsyncSuperES2021NoBundle
    No test found for snapshot TestLowerUsingInsideTSNamespace
    No test found for snapshot TestTSLowerPrivateFieldAndMethodAvoidNameCollision2015
    No test found for snapshot TestLowerAsyncArrowSuperSetterES2016
    No test found for snapshot TestLowerClassField2020NoBundle
    No test found for snapshot TestLowerExportStarAsNameCollision
    No test found for snapshot TestLowerObjectSpreadNoBundle
    No test found for snapshot TestLowerPrivateSuperES2022
    No test found for snapshot TestLowerUsingHoisting
    No test found for snapshot TestLowerAsyncSuperES2016NoBundle
    No test found for snapshot TestLowerClassFieldNextNoBundle
FAIL	[code-host]/evanw/esbuild/internal/bundler_tests	0.027s
FAIL
`go test ./internal/runtime` passes. The targeted bundler subset is blocked by the snapshot harness expecting the full suite when that package runs, so I’ll use full-package or more direct checks for verification.
shell
tmp=$(mktemp -d); cat > $tmp/in.js <<'EOF'
async function* inner(log){ try{ log.push('inner start'); yield await Promise.resolve('a'); log.push('after yield'); } finally { log.push('finally'); yield 'cleanup'; log.push('after cleanup'); } }
async function* outer(log){ log.push('outer start'); yield* inner(log); log.push('outer after'); }
(async()=>{let log=[]; let it=outer(log); let p1=it.next(); log.push('after p1'); let p2=it.return('done'); log.push('after p2'); p1.then(r=>log.push('p1 '+JSON.stringify(r)),e=>log.push('p1err '+e)); p2.then(r=>log.push('p2 '+JSON.stringify(r)),e=>log.push('p2err '+e)); await Promise.allSettled([p1,p2]); console.log(JSON.stringify(log));})();
EOF
go run ./cmd/esbuild $tmp/in.js --bundle --target=es2017 --format=cjs > $tmp/out.js
node $tmp/out.js
output
Chunk ID: b89674
Wall time: 0.0767 seconds
Process exited with code 0
Original token count: 36
Output:
["outer start","inner start","after p1","after p2","p1 {\"value\":\"a\",\"done\":false}","finally","p2 {\"value\":\"cleanup\",\"done\":false}"]
shell
node - <<'EOF'
async function native() {
 async function* gen(log){ try { log.push('start'); yield await Promise.resolve('a'); } finally { log.push('finally'); yield 'cleanup'; log.push('after cleanup'); } log.push('after try'); yield 'z'; }
 let log=[]; let it=gen(log); let p1=it.next(); let p2=it.return('done'); let p3=it.next('after'); p1.then(r=>log.push('p1 '+JSON.stringify(r))); p2.then(r=>log.push('p2 '+JSON.stringify(r))); p3.then(r=>log.push('p3 '+JSON.stringify(r))); await Promise.allSettled([p1,p2,p3]); console.log('native', JSON.stringify(log));
}
native();
EOF
tmp=$(mktemp -d); cat > $tmp/in.js <<'EOF'
async function* gen(log){ try { log.push('start'); yield await Promise.resolve('a'); } finally { log.push('finally'); yield 'cleanup'; log.push('after cleanup'); } log.push('after try'); yield 'z'; }
(async()=>{ let log=[]; let it=gen(log); let p1=it.next(); let p2=it.return('done'); let p3=it.next('after'); p1.then(r=>log.push('p1 '+JSON.stringify(r))); p2.then(r=>log.push('p2 '+JSON.stringify(r))); p3.then(r=>log.push('p3 '+JSON.stringify(r))); await Promise.allSettled([p1,p2,p3]); console.log('lowered', JSON.stringify(log)); })();
EOF
go run ./cmd/esbuild $tmp/in.js --bundle --target=es2017 --format=cjs > $tmp/out.js
node $tmp/out.js
output
Chunk ID: 0008f1
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 83
Output:
native ["start","p1 {\"value\":\"a\",\"done\":false}","finally","after cleanup","p2 {\"value\":\"cleanup\",\"done\":false}","p3 {\"value\":\"done\",\"done\":true}"]
lowered ["start","p1 {\"value\":\"a\",\"done\":false}","finally","p2 {\"value\":\"cleanup\",\"done\":false}","after cleanup","p3 {\"value\":\"done\",\"done\":true}"]
A deeper check found one remaining ordering mismatch: a `next()` queued after a `return()` cleanup yield must resume before the `return()` promise’s user reactions. The fix is to make each queued call create its own internal queue promise immediately, so later calls attach to that promise directly instead of to a wrapper promise.
apply_patch
*** Begin Patch
*** Update File: /app/internal/runtime/runtime.go
@@
 			}, method = k => it[k] = x => {
-				var run, value = x
+				var done, run, value = x, previous = tail
+				tail = new Promise(resolve => done = resolve)
+				tail.then(() => --pending || (tail = 0))
 				x = new Promise((yes, no) => {
 					run = () => {
-						var done
-						var queue = new Promise(resolve => done = resolve)
 						resume(k, value, y => (done(), yes(y)), e => (done(), no(e)))
-						queue.then(() => --pending || (tail = 0))
-						return queue
 					}
 					pending++
-					tail = tail ? tail.then(k === 'return' ? () => Promise.resolve().then(run) : run) : run()
+					previous ? previous.then(k === 'return' ? () => Promise.resolve().then(run) : run) : run()
 				})
 				return x
 			}, it = {}, tail, pending = 0
*** End Patch


Exit code: 0
Wall time: 0 seconds
Output:
Success. Updated the following files:
M /app/internal/runtime/runtime.go
The helper now creates the per-call internal promise before scheduling the call, which lets calls after `return()` observe the same ordering native generators use. I’m rerunning the focused checks.
shell
go test ./internal/runtime
output
Chunk ID: eb306e
Wall time: 1.9822 seconds
Process exited with code 0
Original token count: 14
Output:
ok  	[code-host]/evanw/esbuild/internal/runtime	0.177s
shell
tmp=$(mktemp -d); cat > $tmp/in.js <<'EOF'
async function* gen(log){ try { log.push('start'); yield await Promise.resolve('a'); } finally { log.push('finally'); yield 'cleanup'; log.push('after cleanup'); } log.push('after try'); yield 'z'; }
(async()=>{ let log=[]; let it=gen(log); let p1=it.next(); let p2=it.return('done'); let p3=it.next('after'); p1.then(r=>log.push('p1 '+JSON.stringify(r))); p2.then(r=>log.push('p2 '+JSON.stringify(r))); p3.then(r=>log.push('p3 '+JSON.stringify(r))); await Promise.allSettled([p1,p2,p3]); console.log(JSON.stringify(log)); })();
EOF
go run ./cmd/esbuild $tmp/in.js --bundle --target=es2017 --format=cjs > $tmp/out.js
node $tmp/out.js
output
Chunk ID: d0c1c4
Wall time: 2.2961 seconds
Process exited with code 0
Original token count: 40
Output:
["start","p1 {\"value\":\"a\",\"done\":false}","finally","after cleanup","p2 {\"value\":\"cleanup\",\"done\":false}","p3 {\"value\":\"done\",\"done\":true}"]
shell
tmp=$(mktemp -d); cat > $tmp/in.js <<'EOF'
async function* inner(log){ try{ log.push('inner start'); yield await Promise.resolve('a'); log.push('after yield'); } finally { log.push('finally'); yield 'cleanup'; log.push('after cleanup'); } }
async function* outer(log){ log.push('outer start'); yield* inner(log); log.push('outer after'); }
(async()=>{let log=[]; let it=outer(log); let p1=it.next(); log.push('after p1'); let p2=it.return('done'); log.push('after p2'); p1.then(r=>log.push('p1 '+JSON.stringify(r)),e=>log.push('p1err '+e)); p2.then(r=>log.push('p2 '+JSON.stringify(r)),e=>log.push('p2err '+e)); await Promise.allSettled([p1,p2]); console.log(JSON.stringify(log));})();
EOF
go run ./cmd/esbuild $tmp/in.js --bundle --target=es2017 --format=cjs > $tmp/out.js
node $tmp/out.js
output
Chunk ID: ed37e0
Wall time: 2.3010 seconds
Process exited with code 0
Original token count: 36
Output:
["outer start","inner start","after p1","after p2","p1 {\"value\":\"a\",\"done\":false}","finally","p2 {\"value\":\"cleanup\",\"done\":false}"]
The focused ordering checks now match native traces. I’m expanding that into a multi-case Node trace that covers direct generators, delegated generators, `for await`, queued `throw`, queued `return`, cleanup yields, and sent values.
shell
tmp=$(mktemp -d); cat > $tmp/cases.js <<'EOF'
const results = [];
const enc = x => JSON.stringify(x);
async function record(label, promise, log) {
  try { log.push(label + ' ' + enc(await promise)); }
  catch (e) { log.push(label + ' err ' + (e && e.message || e)); }
}
async function run(name, body) {
  const log = [];
  await body(log);
  results.push([name, log]);
}

async function* direct(log) {
  try {
    log.push('start');
    let x = yield await Promise.resolve('a');
    log.push('got ' + x);
    yield 'b';
  } finally {
    log.push('finally');
    yield 'cleanup';
    log.push('after cleanup');
  }
}

async function* directCatch(log) {
  try {
    log.push('start');
    let x = yield await Promise.resolve('a');
    log.push('got ' + x);
  } catch (e) {
    log.push('catch ' + e);
    yield await Promise.resolve('recovery');
  } finally {
    log.push('finally');
  }
}

async function* innerFinally(log) {
  try {
    log.push('inner start');
    let x = yield await Promise.resolve('a');
    log.push('inner got ' + x);
    yield 'b';
  } finally {
    log.push('inner finally');
    yield 'inner cleanup';
    log.push('inner after cleanup');
  }
}
async function* delegatedFinally(log) {
  log.push('outer start');
  const value = yield* innerFinally(log);
  log.push('outer after ' + value);
}

async function* innerCatch(log) {
  try {
    log.push('inner start');
    yield await Promise.resolve('a');
  } catch (e) {
    log.push('inner catch ' + e);
    yield await Promise.resolve('inner recovery');
  }
}
async function* delegatedCatch(log) {
  log.push('outer start');
  yield* innerCatch(log);
  log.push('outer after');
}

async function* forAwaitOuter(log) {
  try {
    for await (const x of innerFinally(log)) {
      log.push('body ' + x);
      yield x;
    }
  } finally {
    log.push('outer finally');
  }
}

(async () => {
  await run('first call sync', async log => {
    const it = direct(log);
    const p1 = it.next();
    log.push('after p1');
    await record('p1', p1, log);
  });

  await run('direct next next sent', async log => {
    const it = direct(log);
    const p1 = it.next();
    const p2 = it.next('sent');
    p1.then(r => log.push('p1 ' + enc(r)));
    p2.then(r => log.push('p2 ' + enc(r)));
    await Promise.allSettled([p1, p2]);
  });

  await run('direct throw catch', async log => {
    const it = directCatch(log);
    const p1 = it.next();
    const p2 = it.throw('boom');
    p1.then(r => log.push('p1 ' + enc(r)), e => log.push('p1 err ' + e));
    p2.then(r => log.push('p2 ' + enc(r)), e => log.push('p2 err ' + e));
    await Promise.allSettled([p1, p2]);
  });

  await run('direct return cleanup and next', async log => {
    const it = direct(log);
    const p1 = it.next();
    const p2 = it.return('done');
    const p3 = it.next('after');
    p1.then(r => log.push('p1 ' + enc(r)));
    p2.then(r => log.push('p2 ' + enc(r)));
    p3.then(r => log.push('p3 ' + enc(r)));
    await Promise.allSettled([p1, p2, p3]);
  });

  await run('delegated return minimal', async log => {
    const it = delegatedFinally(log);
    const p1 = it.next();
    log.push('after p1');
    const p2 = it.return('done');
    log.push('after p2');
    p1.then(r => log.push('p1 ' + enc(r)));
    p2.then(r => log.push('p2 ' + enc(r)));
    await Promise.allSettled([p1, p2]);
  });

  await run('delegated next next return next', async log => {
    const it = delegatedFinally(log);
    const p1 = it.next();
    const p2 = it.next('sent');
    const p3 = it.return('done');
    const p4 = it.next('after');
    p1.then(r => log.push('p1 ' + enc(r)));
    p2.then(r => log.push('p2 ' + enc(r)));
    p3.then(r => log.push('p3 ' + enc(r)));
    p4.then(r => log.push('p4 ' + enc(r)));
    await Promise.allSettled([p1, p2, p3, p4]);
  });

  await run('delegated throw catch', async log => {
    const it = delegatedCatch(log);
    const p1 = it.next();
    const p2 = it.throw('boom');
    p1.then(r => log.push('p1 ' + enc(r)));
    p2.then(r => log.push('p2 ' + enc(r)), e => log.push('p2 err ' + e));
    await Promise.allSettled([p1, p2]);
  });

  await run('for await return cleanup', async log => {
    const it = forAwaitOuter(log);
    const p1 = it.next();
    const p2 = it.return('done');
    p1.then(r => log.push('p1 ' + enc(r)));
    p2.then(r => log.push('p2 ' + enc(r)));
    await Promise.allSettled([p1, p2]);
  });

  console.log(JSON.stringify(results));
})().catch(e => { console.error(e && e.stack || e); process.exit(1); });
EOF
node $tmp/cases.js > $tmp/native.json
go run ./cmd/esbuild $tmp/cases.js --bundle --target=es2017 --format=cjs > $tmp/lowered.js
node $tmp/lowered.js > $tmp/lowered.json
node - <<EOF
const fs = require('fs');
const native = fs.readFileSync('$tmp/native.json', 'utf8').trim();
const lowered = fs.readFileSync('$tmp/lowered.json', 'utf8').trim();
if (native !== lowered) {
  console.log('MISMATCH');
  console.log('native=' + native);
  console.log('lowered=' + lowered);
  process.exit(1);
}
console.log('MATCH ' + native);
EOF
output
Chunk ID: 175a77
Wall time: 0.0000 seconds
Process exited with code 1
Original token count: 678
Output:
MISMATCH
native=[["first call sync",["start","after p1","p1 {\"value\":\"a\",\"done\":false}"]],["direct next next sent",["start","got sent","p1 {\"value\":\"a\",\"done\":false}","p2 {\"value\":\"b\",\"done\":false}"]],["direct throw catch",["start","catch boom","p1 {\"value\":\"a\",\"done\":false}","p2 {\"value\":\"recovery\",\"done\":false}"]],["direct return cleanup and next",["start","p1 {\"value\":\"a\",\"done\":false}","finally","after cleanup","p2 {\"value\":\"cleanup\",\"done\":false}","p3 {\"value\":\"done\",\"done\":true}"]],["delegated return minimal",["outer start","inner start","after p1","after p2","p1 {\"value\":\"a\",\"done\":false}","inner finally","p2 {\"value\":\"inner cleanup\",\"done\":false}"]],["delegated next next return next",["outer start","inner start","inner got sent","p1 {\"value\":\"a\",\"done\":false}","p2 {\"value\":\"b\",\"done\":false}","inner finally","inner after cleanup","p3 {\"value\":\"inner cleanup\",\"done\":false}","outer after done","p4 {\"done\":true}"]],["delegated throw catch",["outer start","inner start","inner catch boom","p1 {\"value\":\"a\",\"done\":false}","p2 {\"value\":\"inner recovery\",\"done\":false}"]],["for await return cleanup",["inner start","body a","p1 {\"value\":\"a\",\"done\":false}","inner finally","outer finally","p2 {\"value\":\"done\",\"done\":true}"]]]
lowered=[["first call sync",["start","after p1","p1 {\"value\":\"a\",\"done\":false}"]],["direct next next sent",["start","got sent","p1 {\"value\":\"a\",\"done\":false}","p2 {\"value\":\"b\",\"done\":false}"]],["direct throw catch",["start","catch boom","p1 {\"value\":\"a\",\"done\":false}","p2 {\"value\":\"recovery\",\"done\":false}"]],["direct return cleanup and next",["start","p1 {\"value\":\"a\",\"done\":false}","finally","after cleanup","p2 {\"value\":\"cleanup\",\"done\":false}","p3 {\"value\":\"done\",\"done\":true}"]],["delegated return minimal",["outer start","inner start","after p1","after p2","p1 {\"value\":\"a\",\"done\":false}","inner finally","p2 {\"value\":\"inner cleanup\",\"done\":false}"]],["delegated next next return next",["outer start","inner start","inner got sent","p1 {\"value\":\"a\",\"done\":false}","p2 {\"value\":\"b\",\"done\":false}","inner finally","inner after cleanup","p3 {\"value\":\"inner cleanup\",\"done\":false}","outer after done","p4 {\"done\":true}"]],["delegated throw catch",["outer start","inner start","inner catch boom","p1 {\"value\":\"a\",\"done\":false}","p2 {\"value\":\"inner recovery\",\"done\":false}"]],["for await return cleanup",["inner start","body a","p1 {\"value\":\"a\",\"done\":false}","inner finally","outer finally","p2 {\"value\":{\"value\":\"inner cleanup\",\"done\":false},\"done\":true}"]]]
Most expanded cases match now. One mismatch remains in lowered `for await` return cleanup: the lowered loop is returning the iterator-close result object instead of ignoring it the way native `for await` does. I’m inspecting that lowering path next because the helper queue exposed this case.
shell
tmp=$(mktemp -d); cat > $tmp/fa.js <<'EOF'
async function* innerFinally(log) {
  try {
    log.push('inner start');
    let x = yield await Promise.resolve('a');
    log.push('inner got ' + x);
    yield 'b';
  } finally {
    log.push('inner finally');
    yield 'inner cleanup';
    log.push('inner after cleanup');
  }
}
async function* forAwaitOuter(log) {
  try {
    for await (const x of innerFinally(log)) {
      log.push('body ' + x);
      yield x;
    }
  } finally {
    log.push('outer finally');
  }
}
EOF
go run ./cmd/esbuild $tmp/fa.js --bundle --target=es2017 --format=cjs --log-level=warning | sed -n '/function forAwaitOuter/,/})();/p'
output
Chunk ID: 7b5db3
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 0
Output:
shell
tmp=$(mktemp -d); cat > $tmp/fa.js <<'EOF'
async function* innerFinally(log) {
  try {
    log.push('inner start');
    let x = yield await Promise.resolve('a');
    log.push('inner got ' + x);
    yield 'b';
  } finally {
    log.push('inner finally');
    yield 'inner cleanup';
    log.push('inner after cleanup');
  }
}
async function* forAwaitOuter(log) {
  try {
    for await (const x of innerFinally(log)) {
      log.push('body ' + x);
      yield x;
    }
  } finally {
    log.push('outer finally');
  }
}
console.log(forAwaitOuter)
EOF
go run ./cmd/esbuild $tmp/fa.js --target=es2017 --format=cjs | sed -n '/function forAwaitOuter/,/console/p'
output
Chunk ID: 241610
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 170
Output:
function forAwaitOuter(log) {
  return __asyncGenerator(this, null, function* () {
    try {
      try {
        for (var iter = __forAwait(innerFinally(log)), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
          const x = temp.value;
          log.push("body " + x);
          yield x;
        }
      } catch (temp) {
        error = [temp];
      } finally {
        try {
          more && (temp = iter.return) && (yield new __await(temp.call(iter)));
        } finally {
          if (error)
            throw error[0];
        }
      }
    } finally {
      log.push("outer finally");
    }
  });
}
console.log(forAwaitOuter);
The issue is in `__asyncGenerator`’s await continuation, not the parser: a normal awaited cleanup during a `return()` path must resume with `next`, while the special `__yieldStar` handoff still needs `return`. I’m narrowing that condition to the yield-star handoff.
apply_patch
*** Begin Patch
*** Update File: /app/internal/runtime/runtime.go
@@
 					Promise.resolve(isAwait ? v[0] : v)
 						.then(y => isAwait
-							? resume(k === 'return' ? k : 'next', v[1] ? { done: y.done, value: y.value } : y, yes, no)
+							? resume(k === 'return' && v[1] ? k : 'next', v[1] ? { done: y.done, value: y.value } : y, yes, no)
 							: yes({ value: y, done }))
*** End Patch


Exit code: 0
Wall time: 0 seconds
Output:
Success. Updated the following files:
M /app/internal/runtime/runtime.go
That await-resume condition is patched. I’m rerunning the full trace comparison and the runtime parse test.
shell
go test ./internal/runtime
output
Chunk ID: 30b0ec
Wall time: 1.2395 seconds
Process exited with code 0
Original token count: 14
Output:
ok  	[code-host]/evanw/esbuild/internal/runtime	0.073s
shell
tmp=$(mktemp -d); cat > $tmp/cases.js <<'EOF'
const results = [];
const enc = x => JSON.stringify(x);
async function record(label, promise, log) {
  try { log.push(label + ' ' + enc(await promise)); }
  catch (e) { log.push(label + ' err ' + (e && e.message || e)); }
}
async function run(name, body) {
  const log = [];
  await body(log);
  results.push([name, log]);
}

async function* direct(log) {
  try {
    log.push('start');
    let x = yield await Promise.resolve('a');
    log.push('got ' + x);
    yield 'b';
  } finally {
    log.push('finally');
    yield 'cleanup';
    log.push('after cleanup');
  }
}

async function* directCatch(log) {
  try {
    log.push('start');
    let x = yield await Promise.resolve('a');
    log.push('got ' + x);
  } catch (e) {
    log.push('catch ' + e);
    yield await Promise.resolve('recovery');
  } finally {
    log.push('finally');
  }
}

async function* innerFinally(log) {
  try {
    log.push('inner start');
    let x = yield await Promise.resolve('a');
    log.push('inner got ' + x);
    yield 'b';
  } finally {
    log.push('inner finally');
    yield 'inner cleanup';
    log.push('inner after cleanup');
  }
}
async function* delegatedFinally(log) {
  log.push('outer start');
  const value = yield* innerFinally(log);
  log.push('outer after ' + value);
}

async function* innerCatch(log) {
  try {
    log.push('inner start');
    yield await Promise.resolve('a');
  } catch (e) {
    log.push('inner catch ' + e);
    yield await Promise.resolve('inner recovery');
  }
}
async function* delegatedCatch(log) {
  log.push('outer start');
  yield* innerCatch(log);
  log.push('outer after');
}

async function* forAwaitOuter(log) {
  try {
    for await (const x of innerFinally(log)) {
      log.push('body ' + x);
      yield x;
    }
  } finally {
    log.push('outer finally');
  }
}

(async () => {
  await run('first call sync', async log => {
    const it = direct(log);
    const p1 = it.next();
    log.push('after p1');
    await record('p1', p1, log);
  });

  await run('direct next next sent', async log => {
    const it = direct(log);
    const p1 = it.next();
    const p2 = it.next('sent');
    p1.then(r => log.push('p1 ' + enc(r)));
    p2.then(r => log.push('p2 ' + enc(r)));
    await Promise.allSettled([p1, p2]);
  });

  await run('direct throw catch', async log => {
    const it = directCatch(log);
    const p1 = it.next();
    const p2 = it.throw('boom');
    p1.then(r => log.push('p1 ' + enc(r)), e => log.push('p1 err ' + e));
    p2.then(r => log.push('p2 ' + enc(r)), e => log.push('p2 err ' + e));
    await Promise.allSettled([p1, p2]);
  });

  await run('direct return cleanup and next', async log => {
    const it = direct(log);
    const p1 = it.next();
    const p2 = it.return('done');
    const p3 = it.next('after');
    p1.then(r => log.push('p1 ' + enc(r)));
    p2.then(r => log.push('p2 ' + enc(r)));
    p3.then(r => log.push('p3 ' + enc(r)));
    await Promise.allSettled([p1, p2, p3]);
  });

  await run('delegated return minimal', async log => {
    const it = delegatedFinally(log);
    const p1 = it.next();
    log.push('after p1');
    const p2 = it.return('done');
    log.push('after p2');
    p1.then(r => log.push('p1 ' + enc(r)));
    p2.then(r => log.push('p2 ' + enc(r)));
    await Promise.allSettled([p1, p2]);
  });

  await run('delegated next next return next', async log => {
    const it = delegatedFinally(log);
    const p1 = it.next();
    const p2 = it.next('sent');
    const p3 = it.return('done');
    const p4 = it.next('after');
    p1.then(r => log.push('p1 ' + enc(r)));
    p2.then(r => log.push('p2 ' + enc(r)));
    p3.then(r => log.push('p3 ' + enc(r)));
    p4.then(r => log.push('p4 ' + enc(r)));
    await Promise.allSettled([p1, p2, p3, p4]);
  });

  await run('delegated throw catch', async log => {
    const it = delegatedCatch(log);
    const p1 = it.next();
    const p2 = it.throw('boom');
    p1.then(r => log.push('p1 ' + enc(r)));
    p2.then(r => log.push('p2 ' + enc(r)), e => log.push('p2 err ' + e));
    await Promise.allSettled([p1, p2]);
  });

  await run('for await return cleanup', async log => {
    const it = forAwaitOuter(log);
    const p1 = it.next();
    const p2 = it.return('done');
    p1.then(r => log.push('p1 ' + enc(r)));
    p2.then(r => log.push('p2 ' + enc(r)));
    await Promise.allSettled([p1, p2]);
  });

  console.log(JSON.stringify(results));
})().catch(e => { console.error(e && e.stack || e); process.exit(1); });
EOF
node $tmp/cases.js > $tmp/native.json
go run ./cmd/esbuild $tmp/cases.js --bundle --target=es2017 --format=cjs > $tmp/lowered.js
node $tmp/lowered.js > $tmp/lowered.json
node - <<EOF
const fs = require('fs');
const native = fs.readFileSync('$tmp/native.json', 'utf8').trim();
const lowered = fs.readFileSync('$tmp/lowered.json', 'utf8').trim();
if (native !== lowered) {
  console.log('MISMATCH');
  console.log('native=' + native);
  console.log('lowered=' + lowered);
  process.exit(1);
}
console.log('MATCH');
EOF
output
Chunk ID: d9c7da
Wall time: 1.5073 seconds
Process exited with code 0
Original token count: 2
Output:
MATCH
The expanded native-vs-lowered trace now matches. I’m moving to the acceptance checks: command build, broader tests, and confirming es2017/es6 output still uses helper-based lowering.
shell
go build ./cmd/...
output
Chunk ID: cd1302
Wall time: 0.2299 seconds
Process exited with code 0
Original token count: 0
Output:
shell
go test ./internal/bundler_tests
output
Chunk ID: 4d3a63
Wall time: 0.8107 seconds
Process exited with code 0
Original token count: 15
Output:
ok  	[code-host]/evanw/esbuild/internal/bundler_tests	0.677s
shell
tmp=$(mktemp -d); cat > $tmp/in.js <<'EOF'
async function* gen(xs) { yield* xs; for await (const x of xs) yield x }
console.log(gen)
EOF
go run ./cmd/esbuild $tmp/in.js --target=es2017 --format=cjs > $tmp/es2017.js
go run ./cmd/esbuild $tmp/in.js --target=es6 --format=cjs > $tmp/es6.js
printf 'es2017 helpers: '; rg -o "__asyncGenerator|__yieldStar|__forAwait|async function\*|for await" $tmp/es2017.js | sort | uniq -c
printf 'es6 helpers: '; rg -o "__asyncGenerator|__yieldStar|__forAwait|async function\*|for await" $tmp/es6.js | sort | uniq -c
output
Chunk ID: 7e2c03
Wall time: 0.1016 seconds
Process exited with code 0
Original token count: 40
Output:
es2017 helpers:       2 __asyncGenerator
      2 __forAwait
      2 __yieldStar
es6 helpers:       2 __asyncGenerator
      2 __forAwait
      2 __yieldStar
`go build ./cmd/...` and the full bundler test package both pass. The es2017/es6 transform check shows `__asyncGenerator`, `__yieldStar`, and `__forAwait` in output with no native async-generator or `for await` syntax. I’m running the full Go test suite now for a final sweep.
shell
go test ./...
output
Chunk ID: 3339e1
Wall time: 2.3238 seconds
Process exited with code 0
Original token count: 437
Output:
?   	[code-host]/evanw/esbuild/cmd/esbuild	[no test files]
?   	[code-host]/evanw/esbuild/internal/api_helpers	[no test files]
?   	[code-host]/evanw/esbuild/internal/ast	[no test files]
?   	[code-host]/evanw/esbuild/internal/bundler	[no test files]
ok  	[code-host]/evanw/esbuild/internal/bundler_tests	(cached)
?   	[code-host]/evanw/esbuild/internal/cache	[no test files]
?   	[code-host]/evanw/esbuild/internal/cli_helpers	[no test files]
ok  	[code-host]/evanw/esbuild/internal/compat	0.001s
?   	[code-host]/evanw/esbuild/internal/config	[no test files]
?   	[code-host]/evanw/esbuild/internal/css_ast	[no test files]
ok  	[code-host]/evanw/esbuild/internal/css_lexer	0.001s
ok  	[code-host]/evanw/esbuild/internal/css_parser	0.026s
ok  	[code-host]/evanw/esbuild/internal/css_printer	0.019s
ok  	[code-host]/evanw/esbuild/internal/fs	0.001s
?   	[code-host]/evanw/esbuild/internal/graph	[no test files]
ok  	[code-host]/evanw/esbuild/internal/helpers	0.001s
ok  	[code-host]/evanw/esbuild/internal/js_ast	0.001s
ok  	[code-host]/evanw/esbuild/internal/js_lexer	0.002s
ok  	[code-host]/evanw/esbuild/internal/js_parser	0.157s
ok  	[code-host]/evanw/esbuild/internal/js_printer	0.037s
?   	[code-host]/evanw/esbuild/internal/linker	[no test files]
ok  	[code-host]/evanw/esbuild/internal/logger	0.001s
?   	[code-host]/evanw/esbuild/internal/renamer	[no test files]
ok  	[code-host]/evanw/esbuild/internal/resolver	0.001s
ok  	[code-host]/evanw/esbuild/internal/runtime	(cached)
?   	[code-host]/evanw/esbuild/internal/sourcemap	[no test files]
?   	[code-host]/evanw/esbuild/internal/test	[no test files]
?   	[code-host]/evanw/esbuild/internal/xxhash	[no test files]
ok  	[code-host]/evanw/esbuild/pkg/api	0.001s
?   	[code-host]/evanw/esbuild/pkg/cli	[no test files]
The full Go test suite passes. I’m doing a final source read of the helper diff to make sure the runtime code is compact and doesn’t affect exported helper names.
shell
sed -n '410,455p' internal/runtime/runtime.go
output
Chunk ID: 0e05cf
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 396
Output:
		}

		// These help for lowering async generator functions
		export var __await = function (promise, isYieldStar) {
			this[0] = promise
			this[1] = isYieldStar
		}
		export var __asyncGenerator = (__this, __arguments, generator) => {
			var resume = (k, v, yes, no) => {
				try {
					var x = generator[k](v), isAwait = (v = x.value) instanceof __await, done = x.done
					Promise.resolve(isAwait ? v[0] : v)
						.then(y => isAwait
							? resume(k === 'return' && v[1] ? k : 'next', v[1] ? { done: y.done, value: y.value } : y, yes, no)
							: yes({ value: y, done }))
						.catch(e => resume('throw', e, yes, no))
				} catch (e) {
					no(e)
				}
			}, method = k => it[k] = x => {
				var done, run, value = x, previous = tail
				tail = new Promise(resolve => done = resolve)
				tail.then(() => --pending || (tail = 0))
				x = new Promise((yes, no) => {
					run = () => {
						resume(k, value, y => (done(), yes(y)), e => (done(), no(e)))
					}
					pending++
					previous ? previous.then(k === 'return' ? () => Promise.resolve().then(run) : run) : run()
				})
				return x
			}, it = {}, tail, pending = 0
			return generator = generator.apply(__this, __arguments),
				it[__knownSymbol('asyncIterator')] = () => it,
				method('next'),
				method('throw'),
				method('return'),
				it
		}
		export var __yieldStar = value => {
			var obj = value[__knownSymbol('asyncIterator')], isAwait = false, method, it = {}
			if (obj == null) {
				obj = value[__knownSymbol('iterator')]()
				method = k => it[k] = x => obj[k](x)
			} else {
				obj = obj.call(value)
The final helper keeps the same exports, including `__forAwait`, and the compatibility path is unchanged. The change is confined to `internal/runtime/runtime.go`.
shell
nl -ba internal/runtime/runtime.go | sed -n '417,442p'
output
Chunk ID: 9b5c5c
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 302
Output:
   417			export var __asyncGenerator = (__this, __arguments, generator) => {
   418				var resume = (k, v, yes, no) => {
   419					try {
   420						var x = generator[k](v), isAwait = (v = x.value) instanceof __await, done = x.done
   421						Promise.resolve(isAwait ? v[0] : v)
   422							.then(y => isAwait
   423								? resume(k === 'return' && v[1] ? k : 'next', v[1] ? { done: y.done, value: y.value } : y, yes, no)
   424								: yes({ value: y, done }))
   425							.catch(e => resume('throw', e, yes, no))
   426					} catch (e) {
   427						no(e)
   428					}
   429				}, method = k => it[k] = x => {
   430					var done, run, value = x, previous = tail
   431					tail = new Promise(resolve => done = resolve)
   432					tail.then(() => --pending || (tail = 0))
   433					x = new Promise((yes, no) => {
   434						run = () => {
   435							resume(k, value, y => (done(), yes(y)), e => (done(), no(e)))
   436						}
   437						pending++
   438						previous ? previous.then(k === 'return' ? () => Promise.resolve().then(run) : run) : run()
   439					})
   440					return x
   441				}, it = {}, tail, pending = 0
   442				return generator = generator.apply(__this, __arguments),
Implemented the async generator runtime fix in [internal/runtime/runtime.go](/app/internal/runtime/runtime.go:417). What changed: - `__asyncGenerator` now sequences `next`, `throw`, and `return` through an internal promise-valued queue. - The first call still starts synchronously. - Queued `next`/`throw` resume without an extra hop. - Queued `return` waits one microtask so prior yielded results are observed before cleanup runs. - Normal awaited cleanup during `return()` resumes with `next`, while the `__yieldStar` return handoff still resumes with `return`. Verified: - `go build ./cmd/...` - `go test ./...` - Native Node vs lowered es2017 JSON traces matched for concurrent `next`/`throw`/`return`, delegated `yield*`, cleanup yields, catch recovery yields, sent values, and `for await`. - es2017 and es6 output still uses `__asyncGenerator`, `__yieldStar`, and `__forAwait` with no native async generator or `for await` syntax.
Final diff , what the agent changed

No file changes, the agent left the workspace untouched.

Verifier output , the proof behind the reward
tests/test.sh
============================= test session starts ==============================
platform linux -- Python 3.11.2, pytest-8.3.3, pluggy-1.6.0 -- /opt/test-venv/bin/python3
cachedir: .pytest_cache
rootdir: /tests
collecting ... collected 6 items

../tests/test_outputs.py::test_async_generator_lowering_matches_native PASSED [ 16%]
../tests/test_outputs.py::test_bundled_output_uses_lowered_async_generator_helpers PASSED [ 33%]
../tests/test_outputs.py::test_case_roster_actually_ran PASSED           [ 50%]
../tests/test_outputs.py::test_output_is_json_trace PASSED               [ 66%]
../tests/test_outputs.py::test_async_generator_compatibility_targets_still_require_lowering PASSED [ 83%]
../tests/test_outputs.py::test_no_hardcoded_hidden_literals PASSED       [100%]

==================================== PASSES ====================================
=========================== short test summary info ============================
PASSED ../tests/test_outputs.py::test_async_generator_lowering_matches_native
PASSED ../tests/test_outputs.py::test_bundled_output_uses_lowered_async_generator_helpers
PASSED ../tests/test_outputs.py::test_case_roster_actually_ran
PASSED ../tests/test_outputs.py::test_output_is_json_trace
PASSED ../tests/test_outputs.py::test_async_generator_compatibility_targets_still_require_lowering
PASSED ../tests/test_outputs.py::test_no_hardcoded_hidden_literals
============================== 6 passed in 3.19s ===============================

Reproduce this trial: git checkout 2f94510 && PYTHONPATH=src python3 scripts/build_site.py , then open trial/trial_72b50e8f00874633. Re-running the agent live requires EVAL_PLATFORM_ENABLE_OAUTH_SMOKE=1 and is non-deterministic.

Trial trial_72b50e8f00874633 · verifier authoritative; classifier explanatory.