Conversation
The Pascal-case heuristic wrapped any capitalized top-level function with fewer than two declared parameters in the HMR component proxy. A rest parameter counts as a single parameter, so a plain helper such as `function GlobalTest(...arr)` in a `.jsx` file was proxied, and the proxy (`HMRComp(props)`) forwards only its first argument. Calling `GlobalTest(1, 2, 3)` in dev then received just `1`, while the same function in a `.js` file or a production build worked. A component receives at most one argument (its props), so a function declaring a rest parameter can't be one. Skip it in all three wrapping paths (function declarations, variable declarators, and hoisted export declarations) and add snapshot tests for every declaration shape across all bundler and mode suites. Fixes solidjs/solid-vite-plugin#214 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes solidjs/solid-vite-plugin#214
Problem
The Pascal-case heuristic wraps any capitalized top-level function with fewer than two declared parameters in the HMR component proxy. A rest parameter counts as one parameter, so a plain helper in a
.jsxfile likeis wrapped in
$$component. The runtime proxy isHMRComp(props)and forwards only its first argument, soGlobalTest(1, 2, 3)logs just1in dev. The same function in a.jsfile (never transformed) or in a production build (no refresh plugin) works, which is what the reporter saw.Reproduced with the built plugin + runtime in Node: before this change the dev transform yields
1for the function-declaration and arrow forms; after it yields1 2 3for both.Fix
A component receives at most one argument (its props), so a function that declares a rest parameter can't be a component.
isComponentishParamskeeps the existing< 2rule and also rejects aRestElement. It replaces the inlineparams.length < 2check in all three wrapping paths: variable declarators, function declarations, and the hoisting path for export declarations.An alternative would be to have the runtime proxy forward
...args, but that would still route plain functions throughcreateMemo/untrackand register them as components. Skipping them at transform time matches how(a, b)functions are already handled.Tests
Added a "with valid Component name and a rest parameter" case next to each existing ">1 params" case, for all five declaration shapes in all twenty suites (client/server × hydratable × bundler). The new snapshots show the function left untouched; no existing snapshot changed.
🤖 Generated with Claude Code