Skip to content

feat(mdsvex): preprocess mochi:hydrate inside markdown files#22

Merged
khromov merged 4 commits into
mainfrom
mdsvex-hydration
May 23, 2026
Merged

feat(mdsvex): preprocess mochi:hydrate inside markdown files#22
khromov merged 4 commits into
mainfrom
mdsvex-hydration

Conversation

@khromov

@khromov khromov commented May 23, 2026

Copy link
Copy Markdown
Owner

Summary

  • Threads the post-mdsvex Svelte source through preprocessHydratable in ComponentRegistry.ts, so mochi:hydrate, mochi:hydrate:visible, and mochi:defer directives on components inside a .md / .svx file create real islands the same way they do in .svelte pages.
  • Replaces the CSS-checkbox-trick IslandsDemo.svelte on the intro page with a real Svelte 5 component ($state + onclick); the doc invokes it as <IslandsDemo mochi:hydrate />.
  • Updates docs/158-mdsvex.md to document the new capability (drops the old SSR-only warning).

Test plan

  • bun run checks passes (lint + format + typecheck + tests)
  • /docs/intro renders with the <mochi-hydratable-island component-name="IslandsDemo" …> wrapper around the demo and ships a _hydrate-IslandsDemo-*.js client bundle
  • Clicking the Hydrate button toggles the boxes through real Svelte state (gray → green / orange)
  • Other doc pages (/docs/mdsvex, /docs/cache, /docs/hydratable, /docs/lazy-hydration, /docs/coming-from-sveltekit) still render
  • Nested-hydration detector still fires for markdown-sourced islands (uses the same accumulators)

Threads the post-mdsvex Svelte source through preprocessHydratable so
`mochi:hydrate`, `mochi:hydrate:visible`, and `mochi:defer` directives
on components instantiated in `.md` / `.svx` files now create real
islands the same way they do in `.svelte` pages.

Drops the CSS-checkbox trick in `IslandsDemo.svelte` and replaces it
with a real Svelte 5 component (`$state` + onclick), wired via
`<IslandsDemo mochi:hydrate />` on the intro page. Updates the mdsvex
doc page to describe the new capability.
@github-actions

github-actions Bot commented May 23, 2026

Copy link
Copy Markdown
Contributor

Mochi review report

Lines of code (non-blank lines)

packages/mochi

Category main PR Δ
src/ComponentRegistry.ts 1367 1391 +24
Docs 3435 3440 +5
Total 18986 19015 +29

Unchanged: src/**/*.test.ts (5440), src/Mochi.ts (1089), src/hooks.ts (229), src/{requestContext,forms,errors}.ts (247), src/{events,log,logger}.ts (317), src/consoleLogger.ts (342), src/cookies*.ts (157), src/extensions.ts (191), src/cache.ts (60), src/middleware/** (81), src/enhance*.ts (184), src/build*.ts (251), src/proxy.ts (125), src/cli* (110), src/{csrf,serverIslandCrypto}.ts (240), src/{types.ts,*.d.ts} (601), src/web-components/** (431), src/debug-bar/** (1372), src/templates/** (790), Other (1927).

packages/site

Category main PR Δ
Total 9637 9637 0

Unchanged: src/demos/** (5488), src/components/** (2079), src/lib/** (697), src/stores/** (26), Other (1347).

packages/demos

Category main PR Δ
Total 3089 3089 0

Unchanged: src/hn/** (1085), Other (2004).

packages/minimal

Category main PR Δ
Total 537 537 0

Unchanged: Other (537).

packages/cli

Category main PR Δ
Total 502 502 0

Unchanged: src/**/*.test.ts (117), src/cli* (161), src/{create,templates,utils}.ts (220), Other (4).

@khromov khromov merged commit bcf08e4 into main May 23, 2026
3 checks passed
@github-actions github-actions Bot mentioned this pull request May 23, 2026
khromov added a commit that referenced this pull request May 23, 2026
🤖 I have created a release *beep* *boop*
---


<details><summary>mochi-framework: 0.3.0</summary>

##
[0.3.0](mochi-framework-v0.2.0...mochi-framework-v0.3.0)
(2026-05-23)


### Features

* add liveReload option to disable dev WS
([#23](#23))
([616ab7a](616ab7a))
* **mdsvex:** preprocess mochi:hydrate inside markdown files
([#22](#22))
([bcf08e4](bcf08e4))


### Bug Fixes

* **debug-bar:** show green status dot when liveReload is disabled
([#27](#27))
([f8896f5](f8896f5))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Stanislav Khromov <stanislav.khromov+github@gmail.com>
@khromov khromov deleted the mdsvex-hydration branch June 6, 2026 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant