Skip to content

Commit ab93f47

Browse files
committed
Initial implementation of progressive reloading
# Conflicts: # .claude/settings.local.json # README.md
1 parent 6d194c5 commit ab93f47

File tree

14 files changed

+936
-96
lines changed

14 files changed

+936
-96
lines changed

.claude/settings.local.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
"permissions": {
33
"allow": [
44
"Bash(node --test:*)"
5+
"WebFetch(domain:github.com)",
6+
"WebFetch(domain:raw.githubusercontent.com)",
7+
"Bash(gh repo view:*)",
8+
"Bash(gh api:*)"
59
]
610
}
711
}

README.md

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,10 +1444,41 @@ Variable Resolution Layers:
14441444
- **JS pages**: exported vars → page.vars.js → postVars
14451445
- **postVars** - Post-processing function that can modify variables based on all resolved data
14461446

1447+
### Watch Mode Flow
1448+
1449+
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.
1450+
1451+
#### File change decision tree
1452+
1453+
When a file changes under `src`, the chokidar watcher applies this decision tree (first match wins):
1454+
1455+
| File pattern | Action |
1456+
|---|---|
1457+
| `global.vars.*` | Full page rebuild (all pages) |
1458+
| `esbuild.settings.*` | Restart esbuild context + full page rebuild |
1459+
| `markdown-it.settings.*` | Rebuild `.md` pages only |
1460+
| Layout file | Rebuild pages using that layout |
1461+
| Dep of a layout | Rebuild pages using any affected layout |
1462+
| Page file or `page.vars.*` | Rebuild that page + all `postVars` pages |
1463+
| `*.template.*` | Rebuild that template only |
1464+
| Layout CSS/client JS | esbuild watches these itself; its `onEnd` triggers a full page rebuild |
1465+
| (no match) | Skip |
1466+
1467+
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.
1468+
1469+
#### Watched file extensions
1470+
1471+
chokidar watches: `.js`, `.mjs`, `.cjs`, `.ts`, `.mts`, `.cts`, `.css`, `.html`, `.md`
1472+
1473+
cpx watchers handle static asset copying independently and do not trigger page rebuilds.
1474+
1475+
#### `postVars` contagion
1476+
1477+
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.
1478+
14471479
## Roadmap
14481480

1449-
`domstack` works and has a rudimentary watch command, but hasn't been battle tested yet.
1450-
If you end up trying it out, please open any issues or ideas that you have, and feel free to share what you build.
1481+
`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.
14511482

14521483
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.
14531484

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

14931525
## History
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
console.log('This client script runs on the js page')
2+
3+
console.log('hello world!')

examples/basic/src/js-page/loose-assets/page.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { html } from 'htm/preact'
22
import type { PageFunction } from '@domstack/static'
33

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

77
const JSPage: PageFunction<PageVars> = async () => {

examples/basic/src/layouts/child.layout.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import type { LayoutFunction } from '@domstack/static'
22
import { html } from 'htm/preact'
33
import { render } from 'preact-render-to-string'
44

5-
import defaultRootLayout from './root.layout.js'
6-
import type { PageVars } from './root.layout.js'
5+
import defaultRootLayout from './root.layout.ts'
6+
import type { PageVars } from './root.layout.ts'
77

88
const articleLayout: LayoutFunction<PageVars> = (args) => {
99
const { children, ...rest } = args

0 commit comments

Comments
 (0)