|
| 1 | +# Migration Guide: domstack v12 |
| 2 | + |
| 3 | +This guide covers breaking and notable changes when moving from domstack v11 to v12. |
| 4 | + |
| 5 | +If you are migrating from `top-bun`, first follow the historical v11 guide at [v11-migration.md](v11-migration.md), then apply the v12 changes below. |
| 6 | + |
| 7 | +## Table of Contents |
| 8 | + |
| 9 | +1. [Default Layout Uses fragtml](#1-default-layout-uses-fragtml) |
| 10 | +2. [Default Dependencies Changed](#2-default-dependencies-changed) |
| 11 | +3. [JSX Runtime Is Opt-In](#3-jsx-runtime-is-opt-in) |
| 12 | +4. [Preact Examples Stay Preact](#4-preact-examples-stay-preact) |
| 13 | +5. [Development Server Uses @domstack/sync](#5-development-server-uses-domstacksync) |
| 14 | +6. [Migration Checklist](#6-migration-checklist) |
| 15 | + |
| 16 | +--- |
| 17 | + |
| 18 | +## 1. Default Layout Uses fragtml |
| 19 | + |
| 20 | +The bundled default `root.layout.js` now uses [`fragtml`](https://github.com/bcomnes/fragtml#readme) for server-side HTML rendering. |
| 21 | + |
| 22 | +If you rely on the bundled default layout, no action is required. If you previously ejected the default layout and want the v12 default style, update your layout imports and rendering code from Preact/HTM to `fragtml`. |
| 23 | + |
| 24 | +```js |
| 25 | +// Before |
| 26 | +import { html } from 'htm/preact' |
| 27 | +import { render } from 'preact-render-to-string' |
| 28 | +``` |
| 29 | + |
| 30 | +```js |
| 31 | +// After |
| 32 | +import { html, raw, render } from 'fragtml' |
| 33 | +``` |
| 34 | + |
| 35 | +Use `raw(htmlString)` when intentionally inserting already-rendered HTML, such as markdown output passed to a layout as `children`. |
| 36 | + |
| 37 | +--- |
| 38 | + |
| 39 | +## 2. Default Dependencies Changed |
| 40 | + |
| 41 | +The default template no longer includes Preact, HTM, or `preact-render-to-string`. |
| 42 | + |
| 43 | +When you run `domstack --eject`, domstack adds: |
| 44 | + |
| 45 | +- `mine.css` |
| 46 | +- `fragtml` |
| 47 | +- `highlight.js` |
| 48 | + |
| 49 | +It does not add: |
| 50 | + |
| 51 | +- `preact` |
| 52 | +- `htm` |
| 53 | +- `preact-render-to-string` |
| 54 | + |
| 55 | +If your project uses any of those packages directly, keep them in your own `package.json`. |
| 56 | + |
| 57 | +--- |
| 58 | + |
| 59 | +## 3. JSX Runtime Is Opt-In |
| 60 | + |
| 61 | +Client `.jsx` and `.tsx` bundles are still supported through esbuild, but domstack no longer configures Preact as the default JSX runtime. |
| 62 | + |
| 63 | +If your browser client code uses JSX or TSX, install the runtime you want and configure it with `esbuild.settings`. |
| 64 | + |
| 65 | +For Preact: |
| 66 | + |
| 67 | +```sh |
| 68 | +npm install preact |
| 69 | +``` |
| 70 | + |
| 71 | +```js |
| 72 | +// src/esbuild.settings.js |
| 73 | +export default async function esbuildSettingsOverride (esbuildSettings) { |
| 74 | + esbuildSettings.jsx = 'automatic' |
| 75 | + esbuildSettings.jsxImportSource = 'preact' |
| 76 | + |
| 77 | + return esbuildSettings |
| 78 | +} |
| 79 | +``` |
| 80 | + |
| 81 | +For React: |
| 82 | + |
| 83 | +```sh |
| 84 | +npm install react react-dom |
| 85 | +``` |
| 86 | + |
| 87 | +```js |
| 88 | +// src/esbuild.settings.js |
| 89 | +export default async function esbuildSettingsOverride (esbuildSettings) { |
| 90 | + esbuildSettings.jsx = 'automatic' |
| 91 | + esbuildSettings.jsxImportSource = 'react' |
| 92 | + |
| 93 | + return esbuildSettings |
| 94 | +} |
| 95 | +``` |
| 96 | + |
| 97 | +--- |
| 98 | + |
| 99 | +## 4. Preact Examples Stay Preact |
| 100 | + |
| 101 | +Examples that actually mount Preact in the browser still use Preact. Examples that only needed server-side HTML rendering now use `fragtml`. |
| 102 | + |
| 103 | +This means Preact remains a good opt-in client runtime, but it is no longer the default server-side layout dependency. |
| 104 | + |
| 105 | +--- |
| 106 | + |
| 107 | +## 5. Development Server Uses @domstack/sync |
| 108 | + |
| 109 | +Watch/serve mode now uses [`@domstack/sync`](https://www.npmjs.com/package/@domstack/sync) for the local development server. |
| 110 | + |
| 111 | +This provides live reload, CSS injection, ghost mode, and the UI panel. If you were relying on BrowserSync-specific behavior or output, update your expectations around logs, access URLs, and reload handling. |
| 112 | + |
| 113 | +--- |
| 114 | + |
| 115 | +## 6. Migration Checklist |
| 116 | + |
| 117 | +- [ ] If you use an ejected default layout, update it to `fragtml` or keep your existing layout dependencies explicitly. |
| 118 | +- [ ] If you use `htm/preact` or `preact-render-to-string` in server-side layouts/pages, either keep those dependencies or migrate that code to `fragtml`. |
| 119 | +- [ ] If you use `.jsx` or `.tsx` browser clients, add an `esbuild.settings` file that configures your JSX runtime. |
| 120 | +- [ ] If you use Preact browser clients, keep `preact` in your project dependencies. |
| 121 | +- [ ] If you rely on BrowserSync-specific dev-server behavior, test watch mode with `@domstack/sync`. |
0 commit comments