-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix(solid): fix hoisting for solid #5654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughReorders a route-level error component declaration in an e2e Solid Start file and updates the code-splitter compiler to wrap exported Solid components in a getter for TDZ-safe access, plus suppresses inline warnings for Solid targets. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Dev as Developer Code
participant Compiler as Code-Splitter Compiler
participant Output as Compiled Output
note right of Compiler #DDEEFF: compileCodeSplitReferenceRoute
Dev->>Compiler: provide route/component AST
alt targetFramework == "solid" and identifier is exported
Compiler-->>Compiler: wrap reference in getter (TDZ-safe)\nset modified = true\nreturn early
Compiler->>Output: emit getter-wrapped export
else
Compiler->>Compiler: normal split handling
Compiler->>Output: emit normal split code
end
Note over Output: Inline warnings only emitted when\nNODE_ENV != production AND targetFramework != "solid"
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
| Command | Status | Duration | Result |
|---|---|---|---|
nx affected --targets=test:eslint,test:unit,tes... |
❌ Failed | 7m 58s | View ↗ |
nx run-many --target=build --exclude=examples/*... |
✅ Succeeded | 23s | View ↗ |
☁️ Nx Cloud last updated this comment at 2025-10-27 14:25:14 UTC
More templates
@tanstack/arktype-adapter
@tanstack/directive-functions-plugin
@tanstack/eslint-plugin-router
@tanstack/history
@tanstack/nitro-v2-vite-plugin
@tanstack/react-router
@tanstack/react-router-devtools
@tanstack/react-router-ssr-query
@tanstack/react-start
@tanstack/react-start-client
@tanstack/react-start-server
@tanstack/router-cli
@tanstack/router-core
@tanstack/router-devtools
@tanstack/router-devtools-core
@tanstack/router-generator
@tanstack/router-plugin
@tanstack/router-ssr-query-core
@tanstack/router-utils
@tanstack/router-vite-plugin
@tanstack/server-functions-plugin
@tanstack/solid-router
@tanstack/solid-router-devtools
@tanstack/solid-router-ssr-query
@tanstack/solid-start
@tanstack/solid-start-client
@tanstack/solid-start-server
@tanstack/start-client-core
@tanstack/start-plugin-core
@tanstack/start-server-core
@tanstack/start-static-server-functions
@tanstack/start-storage-context
@tanstack/valibot-adapter
@tanstack/virtual-file-routes
@tanstack/zod-adapter
commit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
e2e/solid-start/basic-solid-query/src/routes/posts.$postId.tsx(1 hunks)packages/router-plugin/src/core/code-splitter/compilers.ts(2 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use TypeScript in strict mode with extensive type safety across the codebase
Files:
packages/router-plugin/src/core/code-splitter/compilers.tse2e/solid-start/basic-solid-query/src/routes/posts.$postId.tsx
packages/{router-cli,router-generator,router-plugin,virtual-file-routes}/**
📄 CodeRabbit inference engine (AGENTS.md)
Keep CLI, generators, bundler plugins, and virtual file routing utilities in their dedicated tooling package directories
Files:
packages/router-plugin/src/core/code-splitter/compilers.ts
packages/router-plugin/**
📄 CodeRabbit inference engine (AGENTS.md)
Use unplugin for universal bundler plugins in the router-plugin package
Files:
packages/router-plugin/src/core/code-splitter/compilers.ts
**/src/routes/**
📄 CodeRabbit inference engine (AGENTS.md)
Place file-based routes under src/routes/ directories
Files:
e2e/solid-start/basic-solid-query/src/routes/posts.$postId.tsx
e2e/**
📄 CodeRabbit inference engine (AGENTS.md)
Store end-to-end tests under the e2e/ directory
Files:
e2e/solid-start/basic-solid-query/src/routes/posts.$postId.tsx
🧠 Learnings (1)
📓 Common learnings
Learnt from: CR
PR: TanStack/router#0
File: AGENTS.md:0-0
Timestamp: 2025-09-23T17:36:12.598Z
Learning: Applies to packages/{react-router,solid-router}/** : Implement React and Solid bindings/components only in packages/react-router/ and packages/solid-router/
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Preview
- GitHub Check: Test
🔇 Additional comments (2)
packages/router-plugin/src/core/code-splitter/compilers.ts (1)
454-463: LGTM: Appropriate safeguard for Solid module evaluation.Skipping the inline warning for Solid builds prevents interference with module evaluation order, which is important given the TDZ concerns. The warning is still emitted to console at line 451, so developers are still notified.
e2e/solid-start/basic-solid-query/src/routes/posts.$postId.tsx (1)
13-16: Good demonstration of the TDZ fix, but depends on the critical fix in compilers.ts.Moving
PostErrorComponentbelow theRoutedeclaration effectively demonstrates the temporal dead zone scenario. With the intended fix, the reference at line 9 should be wrapped in a getter to defer evaluation. However, this depends on the control flow issue incompilers.ts(lines 267-283) being resolved.After addressing the critical issue in
compilers.ts, verify that this reordering works correctly by testing that:
- The component reference is wrapped in a getter:
errorComponent: () => PostErrorComponent- No ReferenceError occurs at runtime
- The error component renders correctly when triggered
closes #5646
export function declarations in ES modules are not hoisted - they're treated like export const foo = function(),
creating a temporal dead zone. When you write:
This causes: ReferenceError: Cannot access 'PostErrorComponent' before initialization
For solid, this PR wraps exported component references in getter functions which defers evaluation until after the component is declared.
Summary by CodeRabbit
Summary by CodeRabbit
Bug Fixes
Refactor