#Dev server only hydration directive

4 messages · Page 1 of 1 (latest)

graceful notch
#

Hey folks! I'm working on a project that could really benefit from Astro's tooling, but I'm stuck on one specific problem.

Ultimately I'm trying to build a project that uses web components, but my workflow really benefits from being able to use HMR to maintain state in a component (looks like vue and svelte renderers support this fine). That being said, this workflow is only important during development. When the site is built I'd prefer none of the components to be "hydrated".

What I'm looking for is something along the lines of a client:dev-only directive. I understand there's an upcoming RFC for custom directives, but maybe someone can point me to a config option that I can use in the meantime?

I've also considered writing a intermediary script that clones my src directory and just removes the directive props during build time but that of course sounds pretty damn hacky. Let me know if you have any other ideas though!

full belfryBOT
#
No-one around right now?

It looks like no-one has responded to your question yet. People might not be available right now or don’t know how to answer your question. Want an answer while you wait? Try asking our experimental bot in #1095492539085230272.

devout seal
#

Why hacky ? Does it work ? Do you reach your objective ? Then all good.
In general, I would not recommend any deviation between dev and prod, that's a pain for problems that appear in prod only which you can't test in dev. That being said though your usecase is justified but quite rare. So editing the files automatically as you do is not a bad idea.

graceful notch
#

alright I’ll give it a shot and report back. Thanks for the confidence boost :3