Uncaught Error: Failed attempt to create new DOM elements during hydration. Check that the libraries
This is my first time trying to create solid component with tsup https://github.com/solidjs-community/tsup-preset-solid and I'm assuming I'm doing something wrong π I never seen this error message before so I'm at a loss on where to start debugging this π
setup on library side is pretty minimal, here's my
index.tsx
now on the consumer side I'm trying to call renderHtml
and hydrateHello
. It seem to be working when my component returns a string (instead of jsx) or if I use render
instead of hydrate
but the combination of using hydrate and using html template is what is killing it π« GitHub
GitHub - solidjs-community/tsup-preset-solid: Preset for building y...
Preset for building your SolidJS packages with tsup. - solidjs-community/tsup-preset-solid
17 Replies
the whole error message didn't fit in the title π
GitHub
dom-expressions/packages/dom-expressions/src/client.js at b7a9d9702...
A Fine-Grained Runtime for Performant DOM Rendering - ryansolid/dom-expressions
played with that a bit more from Astro. If I have solid plugin configured for Astro I can just use
.jsx
version of the component and everything works. If I force it to use .js
then I see the same error. I guess that means that package didn't compile solid to plain javascript enough π it still requires some pre-processing of the file before I can use itit looks like that check was added in 0.37.1 version of dom-expressions (https://github.com/ryansolid/dom-expressions/commit/bc52a382e8a20dcd39a697f0fe4776633f6b2700)
https://github.com/solidjs-community/tsup-preset-solid/blob/f711eb2ceb811986c6cbedea44e3e6d0a12fd5a9/src/preset.ts#L250 doesn't take
hydratable
assuming it kept the same API as babel pluginthanks! that's should be there for client build, right?
Both ssr and dom require
hydratable
This is likely intentional and solid pipeline should be integrated to whatever setup because there'd be a couple of output formats if you combine it with js output formats i.e 2 (cjs, esm) * 2 (ssr, dom) * 2 (hydratable, normal) so instead we just simply ship the jsx using solid
export condition and let the solid pipeline handle itthank you so much! I added hydratable and it works now! here's the PR https://github.com/solidjs-community/tsup-preset-solid/pull/11
GitHub
add hydratable: true to solid by JLarky Β· Pull Request #11 Β· solidj...
this is a follow up for a issue I noticed when using this package https://discord.com/channels/722131463138705510/1299231319884169216/1299231319884169216
@davedbase do you know who would be a good person to look at this? π
Yep! @thetarnav has maintained it for a while. I wonder if @amoutonbrady is around and might have an idea as well.
thanks!
Iβm a bit skeptical about it.
The whole point of shipping jsx was that the user would handle how it is compiled.
Now you want to change how the buildless output works? Are you using it in a buildless setup?
Since the precompiled jsx is for a SPA use, the only one you can get with buildless I think, it doesnβt need hydration.
I know there is also an ssr jsx output, but that was just to make the server entries be usable in node.
basically this
I'm reading this as "if you want your solid library code to work with SSR you have to use solid in the app", but that's not what I'm trying to do here
I'm trying to use it from Remix app
the way solid works you kind of have to care about all of those options and you have to have all of those flags on and off depending on how you use it
my problem right now is that solid preset doesn't have a way to set that flag
if it did the way I would like to see it work is something like one entry point for hydratable code, one entry point for SPA
there's of course a bigger issue is that preset doesn't allow you to configure any of the solid options at all π if it did I would have just used that
but if it tries to be opinionated I think it makes sense to have the option of hydratable JSX like there's an option for
dev_entry
this could be useful anyway
but I also wonder what the default should do
At some point the complexity has to be on the user
to precompile the component themselves
Like even if the preset was outputting another, a hydratable entry
How would you use it
export conditions by default only cover server/browser
not ssr/no-ssr
Unless Iβm missing something
Right, I feel like hydratable should be a default, but I can see that this could be not backwards compatible
Regardless if it's a default or not there should be an option to set that value π
Do you want me to work on a PR that could be implementing that?
being about to change plugin options?
That one I wouldnβt mind
okay, I pushed new PR π