Conversation
babel-plugin-jsx-dom-expressions 0.40.10 defaults `omitServerOnlyTemplates` to true, so a `$ServerOnly` element compiles to `getNextElement()` with no template. That only works during hydration; Solid Refresh re-runs the component outside of hydration on every hot update, which then throws `TypeError: template is not a function` and leaves stale DOM. Default `omitServerOnlyTemplates` to false for client transforms while HMR is active (dev server, non-production mode, `hot` not disabled). Server and production transforms keep omitting the template, and an explicit `solid.omitServerOnlyTemplates` setting still wins. Fixes #308 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: b50c064 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
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 #308.
The gap
babel-plugin-jsx-dom-expressions@0.40.10addedomitServerOnlyTemplatesand defaults it totrue. Withhydratable: true, an element marked$ServerOnlythen compiles togetNextElement()with no template argument. That is fine during hydration, butgetNextElementfalls back totemplate()whenever it is not hydrating, so re-creating the element on the client throwsTypeError: template is not a function.Solid Refresh does exactly that on every hot update: it disposes the old root and re-runs the component outside of hydration. So with
solid({ ssr: true })in dev, the first edit of any file containing a$ServerOnlyelement throws and leaves stale DOM (repro: https://github.com/birkskyum/repro-solid-server-only-hmr, downstream report solidjs/solid-start#1930).Fix
The plugin already knows when HMR is active (
needHmr) and whether a transform targets the client. For client transforms while HMR is active it now passesomitServerOnlyTemplates: falsetobabel-preset-solid, so the template stays registered and Solid Refresh can re-create the element. The hydration path is unchanged, sincegetNextElementstill prefers the hydration registry.$ServerOnlymarkup ships to production clients.solid.omitServerOnlyTemplatessetting still takes precedence.Also adds
omitServerOnlyTemplatesto theOptions['solid']type, a README note, and a changeset.Verification
Built the plugin and ran its
transformhook on the repro'sApp.tsxagainstbabel-preset-solid@1.9.15/babel-plugin-jsx-dom-expressions@0.40.10:ssr: true, dev server, client transformgetNextElement(_tmpl$)ssr: true, dev server, server transformssr(...)outputssr: true, dev server,hot: falsegetNextElement()ssr: true, dev server,solid: { omitServerOnlyTemplates: true }getNextElement()ssr: true, production build, client transformgetNextElement()solid: { hydratable: true }withoutssr, dev servergetNextElement(_tmpl$)tsc --emitDeclarationOnlyandprettier --checkpass on the changed files.🤖 Generated with Claude Code