-
-
Notifications
You must be signed in to change notification settings - Fork 3
Convert to fragtml for base layout #260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bcomnes
wants to merge
1
commit into
master
Choose a base branch
from
fragtml
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| # Migration Guide: domstack v12 | ||
|
|
||
| This guide covers breaking and notable changes when moving from domstack v11 to v12. | ||
|
|
||
| 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. | ||
|
|
||
| ## Table of Contents | ||
|
|
||
| 1. [Default Layout Uses fragtml](#1-default-layout-uses-fragtml) | ||
| 2. [Default Dependencies Changed](#2-default-dependencies-changed) | ||
| 3. [JSX Runtime Is Opt-In](#3-jsx-runtime-is-opt-in) | ||
| 4. [Preact Examples Stay Preact](#4-preact-examples-stay-preact) | ||
| 5. [Development Server Uses @domstack/sync](#5-development-server-uses-domstacksync) | ||
| 6. [Migration Checklist](#6-migration-checklist) | ||
|
|
||
| --- | ||
|
|
||
| ## 1. Default Layout Uses fragtml | ||
|
|
||
| The bundled default `root.layout.js` now uses [`fragtml`](https://github.com/bcomnes/fragtml#readme) for server-side HTML rendering. | ||
|
|
||
| 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`. | ||
|
|
||
| ```js | ||
| // Before | ||
| import { html } from 'htm/preact' | ||
| import { render } from 'preact-render-to-string' | ||
| ``` | ||
|
|
||
| ```js | ||
| // After | ||
| import { html, raw, render } from 'fragtml' | ||
| ``` | ||
|
|
||
| Use `raw(htmlString)` when intentionally inserting already-rendered HTML, such as markdown output passed to a layout as `children`. | ||
|
|
||
| --- | ||
|
|
||
| ## 2. Default Dependencies Changed | ||
|
|
||
| The default template no longer includes Preact, HTM, or `preact-render-to-string`. | ||
|
|
||
| When you run `domstack --eject`, domstack adds: | ||
|
|
||
| - `mine.css` | ||
| - `fragtml` | ||
| - `highlight.js` | ||
|
|
||
| It does not add: | ||
|
|
||
| - `preact` | ||
| - `htm` | ||
| - `preact-render-to-string` | ||
|
|
||
| If your project uses any of those packages directly, keep them in your own `package.json`. | ||
|
|
||
| --- | ||
|
|
||
| ## 3. JSX Runtime Is Opt-In | ||
|
|
||
| Client `.jsx` and `.tsx` bundles are still supported through esbuild, but domstack no longer configures Preact as the default JSX runtime. | ||
|
|
||
| If your browser client code uses JSX or TSX, install the runtime you want and configure it with `esbuild.settings`. | ||
|
|
||
| For Preact: | ||
|
|
||
| ```sh | ||
| npm install preact | ||
| ``` | ||
|
|
||
| ```js | ||
| // src/esbuild.settings.js | ||
| export default async function esbuildSettingsOverride (esbuildSettings) { | ||
| esbuildSettings.jsx = 'automatic' | ||
| esbuildSettings.jsxImportSource = 'preact' | ||
|
|
||
| return esbuildSettings | ||
| } | ||
| ``` | ||
|
|
||
| For React: | ||
|
|
||
| ```sh | ||
| npm install react react-dom | ||
| ``` | ||
|
|
||
| ```js | ||
| // src/esbuild.settings.js | ||
| export default async function esbuildSettingsOverride (esbuildSettings) { | ||
| esbuildSettings.jsx = 'automatic' | ||
| esbuildSettings.jsxImportSource = 'react' | ||
|
|
||
| return esbuildSettings | ||
| } | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## 4. Preact Examples Stay Preact | ||
|
|
||
| Examples that actually mount Preact in the browser still use Preact. Examples that only needed server-side HTML rendering now use `fragtml`. | ||
|
|
||
| This means Preact remains a good opt-in client runtime, but it is no longer the default server-side layout dependency. | ||
|
|
||
| --- | ||
|
|
||
| ## 5. Development Server Uses @domstack/sync | ||
|
|
||
| Watch/serve mode now uses [`@domstack/sync`](https://www.npmjs.com/package/@domstack/sync) for the local development server. | ||
|
|
||
| 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. | ||
|
|
||
| --- | ||
|
|
||
| ## 6. Migration Checklist | ||
|
|
||
| - [ ] If you use an ejected default layout, update it to `fragtml` or keep your existing layout dependencies explicitly. | ||
| - [ ] 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`. | ||
| - [ ] If you use `.jsx` or `.tsx` browser clients, add an `esbuild.settings` file that configures your JSX runtime. | ||
| - [ ] If you use Preact browser clients, keep `preact` in your project dependencies. | ||
| - [ ] If you rely on BrowserSync-specific dev-server behavior, test watch mode with `@domstack/sync`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.