Broken reactivity @ `vite-plugin-solid` with `{dev:false}`, but works fine with `{dev:true}`.
Context
- I'm using
render
from solid-js/web
to render content for an Obsidian extension.
- Reactivity is breaking for the Icon
component from @iconify-icon/solid, but the issue is not present when {dev:true}
is set in vite-plugin-solid
.
- I tried troubleshooting this in a minimal StackBlitz Project, but was not able to reproduce the issue.24 Replies
(left side:
{dev:true}
, right side:{dev:false}
)
This is the excerpt of code that's controlling the icon.
hasTag
and sessionContext
are accessors that are managed via xstate
actors.
While debugging, I tried rendering the playButton().icon
string directly instead of passing it to Icon
, and it updates the DOM as expected.
Is this a Solid issue, or an Iconify issue?
looks like an issue with iconify because the props are destructured
https://github.com/iconify/iconify/blob/978ba328940e7749e60a69556b885addfedbb74b/iconify-icon/solid/src/iconify.tsx#L90
although, they are spreading the props later
Just forked it, gonna see if changing that resolves the issue. Any idea why it would have the issue in
{dev:false}
mode but not {dev:true}
?Not too sure tbh, it could be that
{dev:true}
force rerendersNo luck, got rid of the destructuring and the issue is still occurring.
Updated Source Code
Bundled Output
The issue is only for the
Icon
component specifically right?I think so, I haven't noticed it anywhere else.
It works fine in the StackBlitz example though, so I'm not sure what aspects of [Obsidian, Solid, Vite, Iconify, etc.] are playing into the issue in the actual production environment.
Could be an issue with the component being a web component and not playing well with the setup
not sure what's your exact setup but it seems to be working in Obsidian 1.6.3
can't figure out dev setup though 😆
Thanks for the demo. I just replicated it and can confirm that a barebones extension implementation works as expected. However, running the exact same code in my actual extension does not work. Seems like I might have to debug my Vite config... can't think of what sort of thing might cause that issue off the top of my head though 🤔.
Also, just learned about the Iconify IntelliSense VS Code plugin from your setup 🔥.
what do you mean @
can't figure out dev setup
? like hot reloading?(left side:{dev:true}, right side:{dev:false})i assumed you were using solid plugin's hmr somehow i do have this plugin also here interesting the attribute doesn't even update though
my current dev workflow is to just manually run a full build whenever I'm ready to test some changes, haven't been using a build-watch setup.
i ended up finding that
{dev:true}
resolved the issue either through trial and error or might have seen a recommendation about it while researching the issue. before that, I didn't have that option in my config at all.could you try with directly call the icon component like
Icon({ icon: playButton().icon })
?that does work, although it also results in flashing every time something in the dependency chain updates rather than only when the final value is changed. e.g. on every timer tick.
yeah, that would happen
it's really weird this doesn't work
also if you'd like to try
or even this
both of those work 👍
yeh I guess I'll include that as a lib wrapper in my app, thanks for your help with the workarounds!
kinda bugs me that I couldn't track down the root of the issue though... just ran
safe-stringify
on my final vite config (it's built dynamically with a few modules I have for Vite, Solid, Obsidian, etc.) and don't see any glaring issues.feel free to provide extra code, best if it can be copy/pasted to test 😆
could be tough to assemble a 1:1 repro, kinda have like a personal framework of modules that are all contributing a bit to the final output. might take a shot at it when I get a chance.
i did just run into something when trying to implement your Iconify wrapper though. it worked fine when it was in the source code of the Obsidian extension where I'm running into the issue. then I tried moving it to an external module so that I can use it across all of my projects, and the same issue started occurring as with
@iconify-icon/solid
.
that at least narrows it down to something to do with module-sourced components and/or the build process of said modules or the extension itself...