Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .claude/settings.local.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
"permissions": {
"allow": [
"Bash(node --test:*)"
Comment thread
bcomnes marked this conversation as resolved.
"WebFetch(domain:github.com)",
"WebFetch(domain:raw.githubusercontent.com)",
"Bash(gh repo view:*)",
"Bash(gh api:*)"
]
}
}
36 changes: 34 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1444,10 +1444,41 @@ Variable Resolution Layers:
- **JS pages**: exported vars → page.vars.js → postVars
- **postVars** - Post-processing function that can modify variables based on all resolved data

### Watch Mode Flow

Watch mode (`domstack watch` / `DomStack.watch()`) performs an initial build using watch-mode esbuild (stable, non-hashed output filenames) and then keeps the site up to date as files change.

#### File change decision tree

When a file changes under `src`, the chokidar watcher applies this decision tree (first match wins):

| File pattern | Action |
|---|---|
| `global.vars.*` | Full page rebuild (all pages) |
| `esbuild.settings.*` | Restart esbuild context + full page rebuild |
| `markdown-it.settings.*` | Rebuild `.md` pages only |
| Layout file | Rebuild pages using that layout |
| Dep of a layout | Rebuild pages using any affected layout |
| Page file or `page.vars.*` | Rebuild that page + all `postVars` pages |
| `*.template.*` | Rebuild that template only |
| Layout CSS/client JS | esbuild watches these itself; its `onEnd` triggers a full page rebuild |
| (no match) | Skip |

File additions and deletions always trigger a **full structural rebuild**: re-run `identifyPages`, restart the esbuild context, rebuild all pages, and rebuild the watch maps.

#### Watched file extensions

chokidar watches: `.js`, `.mjs`, `.cjs`, `.ts`, `.mts`, `.cts`, `.css`, `.html`, `.md`

cpx watchers handle static asset copying independently and do not trigger page rebuilds.

#### `postVars` contagion

Pages that export a `postVars` function depend on other pages' resolved data. After each full (unfiltered) page build, domstack records which pages used `postVars`. When any page file or vars file subsequently changes, those `postVars` pages are re-rendered alongside the changed page so their cross-page data stays current.

## Roadmap

`domstack` works and has a rudimentary watch command, but hasn't been battle tested yet.
If you end up trying it out, please open any issues or ideas that you have, and feel free to share what you build.
`domstack` is working and actively developed. If you end up trying it out, please open any issues or ideas that you have, and feel free to share what you build.

Some notable features are included below, see the [roadmap](https://github.com/users/bcomnes/projects/3/) for a more in depth view of whats planned.

Expand Down Expand Up @@ -1488,6 +1519,7 @@ Some notable features are included below, see the [roadmap](https://github.com/u
- [x] markdown-it.settings.ts support
- [x] page-worker.worker.ts page worker support
- [x] `page.md` page support
- [x] Progressive watch rebuilds (only rebuild affected pages on change)
- ...[See roadmap](https://github.com/users/bcomnes/projects/3/)

## History
Expand Down
2 changes: 2 additions & 0 deletions examples/basic/src/js-page/client.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
console.log('This client script runs on the js page')

console.log('hello world!')
Comment thread
bcomnes marked this conversation as resolved.
2 changes: 1 addition & 1 deletion examples/basic/src/js-page/loose-assets/page.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { html } from 'htm/preact'
import type { PageFunction } from '@domstack/static'

import sharedData from './shared-lib.js'
import sharedData from './shared-lib.ts'
import type { PageVars } from '../../layouts/root.layout.ts'

const JSPage: PageFunction<PageVars> = async () => {
Expand Down
4 changes: 2 additions & 2 deletions examples/basic/src/layouts/child.layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import type { LayoutFunction } from '@domstack/static'
import { html } from 'htm/preact'
import { render } from 'preact-render-to-string'

import defaultRootLayout from './root.layout.js'
import type { PageVars } from './root.layout.js'
import defaultRootLayout from './root.layout.ts'
import type { PageVars } from './root.layout.ts'

const articleLayout: LayoutFunction<PageVars> = (args) => {
const { children, ...rest } = args
Expand Down
Loading