README: a one-off page pins a commit's build from the esm app
Jonas Templestein, 2026-11-27 19:57 UTC · d46b074b4524b57df44329cb4f83ef1525b42c50 · parent ceceae6
2 files changed
M README.md
@@ -6,7 +6,7 @@ | Building | Use | | ------------------------------------------------------------------ | -------------------------------------------------------------------------- | | An app with a build step, that you'll keep | The shadcn registry: `npx shadcn add https://ui.iterate.com/r/<item>.json` | -| A one-off page with no build (an agent's answer to a request, say) | This package from esm.sh, with an import map | +| A one-off page with no build (an agent's answer to a request, say) | A build of this repo's commit from the esm app, with an import map | `npm install @iterate-com/ui` into an app is not supported (below). @@ -21,8 +21,12 @@ [ui.iterate.com/r/registry.json](https://ui.iterate.com/r/registry.json); setup is in `AGENTS.md` of [the kit's repo](https://git.iterate.com/repos/ui), under "The registry". -## A one-off page: esm.sh +## A one-off page: a commit's build +The esm app of iterate's mind builds each commit of this repo's `main` and serves the build for +good at `https://esm-sh.iterate.com/repos/ui@<commit>/<export>`. No npm and no esm.sh is between a +commit and a page. + A page an agent might write when asked what happened in an email thread: its worker answers `./events` with the thread's context's events, and the page shows them in the stream viewer, polling for new ones. @@ -36,18 +40,18 @@ <script type="importmap"> { "imports": { - "@iterate-com/ui/": "https://esm.iterate.com/@iterate-com/ui@<version>/", - "react": "https://esm.iterate.com/@iterate-com/ui@<version>/react", - "react/": "https://esm.iterate.com/@iterate-com/ui@<version>/react/", - "react-dom": "https://esm.iterate.com/@iterate-com/ui@<version>/react-dom", - "react-dom/": "https://esm.iterate.com/@iterate-com/ui@<version>/react-dom/", - "@tanstack/react-query": "https://esm.iterate.com/@tanstack/react-query@5?external=react,react-dom" + "@iterate-com/ui/": "https://esm-sh.iterate.com/repos/ui@<commit>/", + "react": "https://esm-sh.iterate.com/repos/ui@<commit>/react", + "react/": "https://esm-sh.iterate.com/repos/ui@<commit>/react/", + "react-dom": "https://esm-sh.iterate.com/repos/ui@<commit>/react-dom", + "react-dom/": "https://esm-sh.iterate.com/repos/ui@<commit>/react-dom/", + "@tanstack/react-query": "https://esm-sh.iterate.com/@tanstack/react-query@5?external=react,react-dom" } } </script> - <link rel="stylesheet" href="https://esm.iterate.com/@iterate-com/ui@<version>/styles.css" /> + <link rel="stylesheet" href="https://esm-sh.iterate.com/repos/ui@<commit>/styles.css" /> <!-- optional: iterate's look (Ubuntu, square corners) over the neutral one --> - <link rel="stylesheet" href="https://esm.iterate.com/@iterate-com/ui@<version>/iterate.css" /> + <link rel="stylesheet" href="https://esm-sh.iterate.com/repos/ui@<commit>/iterate.css" /> </head> <body> <script type="module"> @@ -97,11 +101,25 @@ </html> ``` -- `<version>` is exact: the `main` dist-tag's, from `npm view @iterate-com/ui dist-tags.main`. +- `<commit>` is the newest commit that is BUILT, whole (40 characters). Ask the esm app for it, not + `git log`: a commit of `main` has no build for about 90 seconds after its push. + + ```sh + curl -s https://esm-sh.iterate.com/repos/ui + # { "name": "ui", "commit": "ceceae6e052ee8c76c25106872ee4c6010327a42", "state": "built", "exports": [ "page", … ] } + ``` + + It answers JSON to any request: no `Accept` header is needed. `exports` lists what a page can + import. `https://esm-sh.iterate.com/repos/ui@<commit>` says the state of one commit's build. + +- **Pin the commit.** `https://esm-sh.iterate.com/repos/ui/<export>`, with no commit, is a redirect + to the newest build, for a look by hand. Never put it in an import map: the page would change + under you, and its modules would come from two builds. - `html` is [htm](https://github.com/developit/htm): JSX's shape in a template string, so the page needs no compiler. -- React is the package's own. Load any other React library from esm.sh with - `?external=react,react-dom` and it uses the same one, as react-query does here. A chart library +- React is the package's own. Load any other React library from esm.sh's address for it on the + same host (`https://esm-sh.iterate.com/<package>@<version>`, which passes the request on to + public esm.sh) with `?external=react,react-dom`, and it uses the same one, as react-query does here. A chart library beside our components, and what goes wrong without the flag: "Another React library" in `examples/README.md` of [the kit's repo](https://git.iterate.com/repos/ui). - Components are `@iterate-com/ui/components/<name>`: `context-view/context-view`, @@ -117,10 +135,7 @@ On a plain HTML page, one script tag defines `<change-my-mind>`, with no React and no stylesheet: ```html -<script - type="module" - src="https://esm.iterate.com/@iterate-com/ui@<version>/change-my-mind" -></script> +<script type="module" src="https://esm-sh.iterate.com/repos/ui@<commit>/change-my-mind"></script> <change-my-mind source="https://blog.example.com/a-post"></change-my-mind> ```
M examples/README.md
@@ -1,6 +1,6 @@ # No-build pages -Each file here is a whole page that imports `@iterate-com/ui` from esm.sh, to copy and change. The +Each file here is a whole page that imports `@iterate-com/ui` from a URL, to copy and change. The package [README](../README.md) shows the import map and a first page. > [!WARNING] @@ -9,19 +9,21 @@ > pages name). The browser specs that proved them left the repository with that platform. They are > not yet proven against a mind stack. -- **Pin a version.** `<version>` is exact, for example the `main` dist-tag of - `https://registry.npmjs.org/@iterate-com/ui` on the day you write the page. +- **Pin a commit.** The package [README](../README.md) says the address, + `https://esm-sh.iterate.com/repos/ui@<commit>/`, and where the newest built commit comes from. The + pages here still name the old address (`https://esm.iterate.com/@iterate-com/ui@<version>/`, a + version of npm): change it when you copy one. - **Use path-shaped URLs only.** The browser cannot prefix-map a URL with a `?query`: it drops the query when it resolves a subpath against it. ## Another React library `events-chart-page.ts` charts a context's events with recharts, above the same context in -`ContextView`. A library loads from esm.sh with `?external=react,react-dom`, which leaves its React +`ContextView`. A library loads from esm.sh, through `esm-sh.iterate.com`, with `?external=react,react-dom`, which leaves its React imports to the page's import map, so it uses the React that this package bundles: ```json -"recharts": "https://esm.iterate.com/recharts@3.10.1?external=react,react-dom" +"recharts": "https://esm-sh.iterate.com/recharts@3.10.1?external=react,react-dom" ``` - **Without the flag**, esm.sh gives the library its own React. The page is blank and the console