Avatar for the oxc-project user
oxc-project
oxc
BlogDocsChangelog

Performance History

Latest Results

fix(transformer): correct scope of inferred named FE in async-to-generator When the async-to-generator transform wraps an async arrow / anonymous async function expression whose name is inferred from its parent (e.g. `const foo = async () => {}`, `{ foo: async () => {} }`), it emits a named function expression as the caller: ```js const foo = function () { var _ref = asyncToGenerator(function* () { /* body */ }); return function foo() { return _ref.apply(this, arguments); }; }(); ``` Per the JS spec, the inferred name `foo` binds only inside the named FE itself — not in the enclosing wrapper IIFE scope. But the previous code had two bugs that together caused oxc to emit an AST that a fresh semantic analysis would misread: 1. `create_function` set `FunctionType::FunctionDeclaration` whenever `id.is_some()`, even for callers using the result as a function expression. Any fresh semantic pass on the output trusts `r#type` and treats the node as a declaration — which binds the name in the enclosing wrapper scope. 2. The inferred id's binding was registered in `wrapper_scope_id` rather than the function's own scope. Combined, they cause downstream tools (e.g. Rolldown's minifier in Vite) to resolve a body reference like `typeNext()` inside `const typeNext = async () => { typeNext(); }` to the inner caller instead of the outer `const typeNext`. The outer const then looks unused, gets inlined away, and the body reference fails at runtime with a `ReferenceError`. Fix: pass `FunctionType` explicitly (via new `create_function_expression` and `create_function_declaration` helpers), and place the inferred id's binding in the caller function's own scope. Closes #21125 Closes #21445 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
fix/async-to-generator-inferred-name-scope
29 minutes ago
fix(transformer): correct scope of inferred named FE in async-to-generator When the async-to-generator transform wraps an async arrow / anonymous async function expression whose name is inferred from its parent (e.g. `const foo = async () => {}`, `{ foo: async () => {} }`), it emits a named function expression as the caller: ```js const foo = function () { var _ref = asyncToGenerator(function* () { /* body */ }); return function foo() { return _ref.apply(this, arguments); }; }(); ``` Per the JS spec, the inferred name `foo` binds only inside the named FE itself — not in the enclosing wrapper IIFE scope. But the previous code had two bugs that together caused oxc to emit an AST that a fresh semantic analysis would misread: 1. `create_function` set `FunctionType::FunctionDeclaration` whenever `id.is_some()`, even for callers using the result as a function expression. Any fresh semantic pass on the output trusts `r#type` and treats the node as a declaration — which binds the name in the enclosing wrapper scope. 2. The inferred id's binding was registered in `wrapper_scope_id` rather than the function's own scope. Combined, they cause downstream tools (e.g. Rolldown's minifier in Vite) to resolve a body reference like `typeNext()` inside `const typeNext = async () => { typeNext(); }` to the inner caller instead of the outer `const typeNext`. The outer const then looks unused, gets inlined away, and the body reference fails at runtime with a `ReferenceError`. Fix: pass `FunctionType` explicitly (via new `create_function_expression` and `create_function_declaration` helpers), and place the inferred id's binding in the caller function's own scope. Closes #21125 Closes #21445 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
fix/async-to-generator-inferred-name-scope
41 minutes ago
Merge branch 'main' into fix/minifier-rewrite-arguments-copy-loop
fazba:fix/minifier-rewrite-arguments-copy-loop
6 hours ago

Latest Branches

CodSpeed Performance Gauge
0%
fix(transformer): correct scope of inferred named FE in async-to-generator#21458
1 hour ago
a21b1f6
fix/async-to-generator-inferred-name-scope
CodSpeed Performance Gauge
0%
4 hours ago
1860cc7
fix/update-expression-side-effects
CodSpeed Performance Gauge
0%
19 days ago
6a0e43f
kane50613:main
© 2026 CodSpeed Technology
Home Terms Privacy Docs