Repository navigation
fix(compiler): compile anonymous default-exported @{} components - #1842
Merged
Merged
Conversation
`export default function () @{ … }` crashed client, server, and HMR compiles
with `Cannot read properties of null (reading 'name')`: component lowering
addresses the compiled function through its declaration binding, and an
anonymous default declaration has none.
Give the anonymous component a synthesized module binding (`_default`,
suffixed past any authored identifier) right after arrow-component
normalization in both the client and server pipelines, so it compiles exactly
like `export default function Name() @{ … }`: capability stamps, dev LOC,
HMR registration under the `default` export, and the void-root contract that
findVoidComponentExports already certified. Async and generator anonymous
components are rejected with an error naming `default`, not the synthesized
binding.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
… on its compiled output Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
marked this pull request as ready for review
October 7, 2026 10:40
Contributor
Benchmark report🟢 No budget breaches, no added work, and no timing changes beyond ±3%. Compares js-framework: 1k/10k row operationsAll 20 timed operations (20 without a verdict)
All 64 work counters are unchanged. Application bundle size (bytes)No changes across 60 measured values. Public-import reachability bundles (bytes)No changes across 108 measured values. |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website | 15104d5 | Commit Preview URL Branch Preview URL |
Oct 07 2026, 11:00 AM |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website-mcp | 15104d5 | Commit Preview URL Branch Preview URL |
Oct 07 2026, 11:02 AM |
3 of 6 tasks
trueadm
added a commit
that referenced
this pull request
Oct 7, 2026
Conflicts: the 87 react-parity manifests and the user-apps-v1 manifest record the lockfile hash, which main changed by adding jsdom to the codegen-size benchmark (#1840); pnpm sync regenerated them. The merged lockfile needs no changes from `pnpm install --lockfile-only`. The new anonymous-default-component fixture (#1842) is already in the new layout and compiles in both modes; #1842's tests pass on this branch's parser. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
export default function () @{ <p>D</p>; }crashed every DOM compile (client prod, client dev, Vite and webpack HMR, and server) withTypeError: Cannot read properties of null (reading 'name')incompileComponent/compileServerComponent. Component lowering addresses the compiled function through its declaration binding for capability stamps (__s,markWarm), the HMR rebinding, dev__oct_loc, and profile registration. An anonymous default declaration has no binding.The parenthesized form
export default (function () @{ … })crashed the same way. Found while fixing #1839: #1840 had to use a named default export in its fixture.Fix. A new copy-on-write pass,
nameAnonymousDefaultComponent, runs right afternormalizeArrowComponentsin both the client (compileInternal) and server (compileServer) pipelines. It gives the anonymous@{}component a synthesized module binding:_default, Babel's convention. It is allocated with the existingallocCompilerName/collectIdentifierNames, so it becomes_default$and so on when an authored identifier already uses the name.export default function Name() @{ … }.default.default.findVoidComponentExportsalready certified'default'for this shape. That claim is now true of the compiled output too, and it matches theanalyzeCompiledModulere-proof added in perf(rspack-plugin): specialize imported void roots and component calls in production builds #1840.default, not the synthesized binding.Visible naming. The component's
fn.name, which runtime diagnostics print, is_default, as in Babel's CJS output. Its profile metadata name is_defaulttoo. The profile pipeline uses the metadata name as the registration binding, so the two must match. Native ESM would infer the namedefault, but every name-carrying shape needs a binding, so that name can't be kept.Unchanged:
__octaneUniversalDefault.export default () => @{ … }, which takes the generic value path. See follow-ups.Validation
component-mount-shapes.test.ts: the file failed to import its fixture.hmr.test.ts: the twodefaultcases failed.local-void-root.test.ts: the new case failed.void-root-exports.test.ts: the re-proof case failed with the fix unwired.'_default'instead of allocating makes the fixture throwSyntaxError: Identifier '_default' has already been declared. The fixture declares an authoredconst _default.rejectAsyncOrGenerator(…, 'default')call makes the new compile-errors cases fail withComponent \_default` is declared…`.--project octaneonly, per the local test-load rule:component-mount-shapes,hmr,local-void-root,compiler/compile-errors,compiler/void-root-exports, plus the neighbouringcompiler/compile-dev-loc,compiler/compile-profile,compiler/islands-shell,compiler/strong-modeandconformance/server-integration-matrix. All passed: 1,427 tests before the rebase onto perf(rspack-plugin): specialize imported void roots and component calls in production builds #1840, and 150 + 4 on the rebased files.export default function P(props)for 10 component shapes across 11 modes: prod, dev, vite HMR, webpack HMR, server, server dev, profile, Strong, inspect, and native reads on client and server. The shapes were hooks,use(),<Hydrate>islands, scoped<style>, a null guard,@try,@for, child components, context andderived$. All 110 outputs are byte-identical once the binding name, source-text hashes and the file name are normalized.pnpm format:files:checkon every changed filenode scripts/react-parity/check.mjs --validate-onlypnpm sync(no generated changes)pnpm typecheck:fileson the changed files and fixture. No errors in new code. It still reports two existing errors in untouched code:scope-lazy-collections.tsrxTS7006 andcompile-errors.test.ts:573TS2769.pnpm format:check,pnpm typecheck,pnpm test: left to CI. Theoctane-prodproject was not run locally. The production client compile is exercised bylocal-void-root(dev: false, hmr: false).Performance. No runtime or bundle change; the only output change is for input that used to crash. Compile cost per module is one
findIndexover top-level statements. An identifier walk runs only when an anonymous default@{}component exists. No benchmark was run because there is no measurable path.Risk / follow-ups
export default () => @{ … }(arrow) still compiles through the generic value path. It works, but it gets no HMR wrapper or accept block and no__sstamp. Normalizing it to the same named form would be a small follow-up.export default (function Name() @{ … })(a named function expression) emitsconst Name = …. That collides with an existing module bindingName, which JavaScript semantics would allow. This pre-existing issue is untouched here.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Low Risk
Targeted compiler AST normalization for a previously crashing input shape; no intentional runtime behavior change for code that already compiled, with broad test coverage on client, server, HMR, and bundler void-export paths.
Overview
Fixes a compiler crash when modules use
export default function () @{ … }: component lowering expected a declaration binding and threwCannot read properties of null (reading 'name')on client, server, and HMR builds.A new copy-on-write AST pass,
nameAnonymousDefaultComponent, runs afternormalizeArrowComponentson both client and server pipelines. It assigns a collision-safe synthesized id (typically_default, viaallocCompilerName) to the anonymous@{}function while keeping the public export asdefault, so stamps, HMR, dev metadata, and void-root specialization behave like a named default component. Async and generator anonymous defaults are rejected with diagnostics that refer todefault, not the synthesized binding.Tests cover mount/update, SSR, hydration, HMR under
default, void-export re-proof, production__createVoidRootspecialization, and a fixture with an authored_defaultbinding to guard name allocation.Reviewed by Cursor Bugbot for commit 15104d5. Bugbot is set up for automated code reviews on this repo. Configure here.