Date sitemap lastmod from the build pipeline; warn on skipped pages
- bunext build records when each page's client bundle hash last changed
in .bunext/page-lastmod.json (sitemap.lastmod_file to relocate). The
hash covers the page's whole import graph, so component edits re-date
every page that uses them. The sitemap uses these dates as lastmod
- Add sitemap.default_lastmod
- BREAKING: use_file_lastmod now defaults to false (file mtimes are reset
by checkouts); it is a fallback after the build record
- Warn when a page or __root.tsx is skipped because its default export
is not at the start of a line (e.g. export { Page as default })
- Replace leaking module mocks in tests (log, grab-root-file-path) with
spies and fixtures
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -39,6 +39,7 @@ The goal is a framework that is:
|
||||
- [Sitemap](#sitemap)
|
||||
- [Page `sitemap` Export](#page-sitemap-export)
|
||||
- [`bunext sitemap` Command](#bunext-sitemap-command)
|
||||
- [Last-Modified Dates](#last-modified-dates)
|
||||
- [Large Sitemaps](#large-sitemaps)
|
||||
- [Generating at Runtime](#generating-at-runtime)
|
||||
- [robots.txt](#robotstxt)
|
||||
@@ -702,6 +703,23 @@ bunext sitemap --origin https://staging.example.com
|
||||
bunext sitemap --no-robots # sitemap only
|
||||
```
|
||||
|
||||
#### Last-Modified Dates
|
||||
|
||||
`lastmod` comes from the build pipeline. On every `bunext build`, Bunext compares each page's client bundle hash with the previous build and records the build date for pages whose bundle changed in `.bunext/page-lastmod.json`. The hash covers the page's whole import graph, so editing a shared component re-dates every page that uses it, while untouched pages keep their date. Editing `__root.tsx` changes every page.
|
||||
|
||||
Each URL's `lastmod` is the first of:
|
||||
|
||||
1. The entry's own `lastmod` (from `additional_paths` or a page's `sitemap` export)
|
||||
2. The page's date from the build record (also used for entries returned by that page's `sitemap` export)
|
||||
3. The page file's modification time, if `use_file_lastmod: true`
|
||||
4. `default_lastmod`
|
||||
|
||||
With no date, `<lastmod>` is left out. Run `bunext build` before `bunext sitemap`; the command warns when there is no record.
|
||||
|
||||
- **The record must persist between builds.** Without the previous record, every page is dated with the current build. Building on the server you deploy to keeps `.bunext/` between builds. For CI builds from a fresh checkout, set `sitemap.lastmod_file` to a path you cache between runs or commit (it is sorted JSON for small diffs).
|
||||
- **Server data is not covered.** Content loaded in a server function (e.g. from a database) does not change the bundle, so set `lastmod` on those entries in the page's `sitemap` export.
|
||||
- Upgrading esbuild or changing build options can change every hash once, re-dating all pages.
|
||||
|
||||
#### Large Sitemaps
|
||||
|
||||
A sitemap file may hold at most 50,000 URLs and 50MB. When the sitemap has more than `chunk_size` URLs (default 10,000), `bunext sitemap` splits it into chunk files and makes `sitemap.xml` a sitemap index pointing to them:
|
||||
@@ -756,7 +774,9 @@ export default async function handler(req: Request) {
|
||||
| `origin` | `string` | Base URL for each `<loc>`. Defaults to `config.origin`, then `http://localhost:<port>`. |
|
||||
| `exclude` | `(string \| RegExp)[]` | Exact paths, subtrees ending in `/*` (`/admin/*` also excludes `/admin`), or regexes tested on the path. |
|
||||
| `additional_paths` | `entries \| () => entries \| Promise<entries>` | Extra paths or entries (`path`, `lastmod`, `changefreq`, `priority`), or a sync/async function returning them, e.g. for dynamic routes. Each entry is a `string` or `BunextSitemapEntry`. |
|
||||
| `use_file_lastmod` | `boolean` | Use each page file's modification time as `lastmod`. Default `true`. |
|
||||
| `default_lastmod` | `Date \| string` | `lastmod` for entries with no other date. See [Last-Modified Dates](#last-modified-dates). |
|
||||
| `lastmod_file` | `string` | Page date record written by `bunext build`. Default `.bunext/page-lastmod.json`. |
|
||||
| `use_file_lastmod` | `boolean` | Fall back to each page file's modification time. Default `false`. |
|
||||
| `trailing_slash` | `boolean` | Append `/` to every non-root path. Default `false`. |
|
||||
| `default_changefreq` | `BunextSitemapChangeFreq` | `changefreq` for entries that do not set one. |
|
||||
| `default_priority` | `number` | `priority` (0.0 to 1.0) for entries that do not set one. |
|
||||
|
||||
Reference in New Issue
Block a user