@ultimat3/cli 31.14.0 → 31.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +1 -1
- package/README.md +2 -1
- package/package.json +29 -29
- package/src/budgets-requests.ts +37 -0
- package/src/budgets.ts +20 -1
- package/src/dev-boot.ts +2 -2
- package/src/dev-route-table.ts +5 -9
- package/src/document-options.ts +0 -7
- package/src/island-bundle.ts +52 -12
- package/src/island-disposer.ts +1 -1
- package/src/island-group-cache.ts +4 -0
- package/src/island-link-check.ts +73 -0
- package/src/island-vendor.ts +183 -0
- package/src/mcp-errors.ts +1 -1
- package/src/prerender.ts +7 -7
- package/src/route-islands-preload.ts +54 -11
- package/src/runtime-admin.ts +2 -4
- package/src/runtime-render-document.ts +34 -13
- package/src/runtime-render.ts +58 -30
- package/src/serve-web.ts +8 -11
- package/src/static-images.ts +25 -4
- package/src/static-precompress.ts +57 -0
- package/src/style-bundle.ts +28 -6
- package/src/templates/guard-island-mount-clears.ts +151 -0
- package/src/templates/island.ts +8 -7
- package/src/templates/resource-form-island.ts +12 -9
- package/src/templates/scaffold-docs.ts +1 -0
- package/src/templates/scaffold-guards.ts +4 -1
- package/src/templates/scaffold-shell.ts +12 -9
- package/src/theme-brand.ts +18 -20
- package/wiki/Client-Data.md +52 -0
- package/wiki/Configuration.md +1 -0
- package/wiki/MCP-And-AI.md +42 -1
- package/wiki/Notify.md +6 -0
- package/wiki/PWA-And-Offline.md +11 -0
- package/wiki/Realtime.md +4 -3
- package/wiki/SEO.md +1 -1
- package/wiki/Static-Assets.md +30 -3
- package/wiki/Theming.md +6 -6
- package/wiki/Upgrading.md +8 -0
package/CLAUDE.md
CHANGED
|
@@ -149,7 +149,7 @@ Commands: `bun test ./packages/cli/` (repo root: the preload),
|
|
|
149
149
|
| `page-navigation.ts` | the client router for `navigation.client` surfaces — built, routed and named ONCE for `x dev`, the container and the static export; none opted in builds nothing |
|
|
150
150
|
| `page-speculation.ts` | Speculation Rules for documents WITHOUT the router (`navigation.speculation`): an allow-list of pure-read pages ‡ |
|
|
151
151
|
| `static-document.ts` | a served `static` page: `304` on `If-None-Match`; container keeps the document (never `x dev`) † |
|
|
152
|
-
| `island-{bundle,groups,outputs,build-pool,group-cache,cache-inputs,store,sources,runtime}.ts` / `island-realtime*.ts` / `solid-loader.ts` | islands, named by their final bytes (#1075): one `Bun.build` per route group — islands on exactly the same routes split together, every other alone; groups read from `page.tsx` sources, the one input every caller has before rendering (`islands.sharedChunks` = one group). A group's output is reused from `.x/cache/islands/` while every file it read (Sass partials included), every directory listing it resolved in and the lockfile/tsconfig/`package.json` environment hash the same (`reuse: false` for a determinism test) † |
|
|
152
|
+
| `island-{bundle,groups,outputs,build-pool,group-cache,cache-inputs,store,sources,runtime}.ts` / `island-realtime*.ts` / `solid-loader.ts` | islands, named by their final bytes (#1075): one `Bun.build` per route group — islands on exactly the same routes split together, every other alone; groups read from `page.tsx` sources, the one input every caller has before rendering (`islands.sharedChunks` = one group). A group's output is reused from `.x/cache/islands/` while every file it read (Sass partials included), every directory listing it resolved in and the lockfile/tsconfig/`package.json` environment hash the same (`reuse: false` for a determinism test). `islands.vendorSolid` (`island-vendor.ts`, off: a regression on every tracked app) builds Solid once as `vendor-solid.<hash>.js` every island imports; `island-link-check.ts` refuses a merged bundle whose import names bind nothing (#1075's smoke) † |
|
|
153
153
|
| `local-cli.ts` / `local-cli-handoff.ts` | a global `x` hands over to the app's own CLI (`local-cli.ts` decides whether; `x upgrade` alone stays when the app's is strictly older — `upgrade-handover.test.ts`) |
|
|
154
154
|
| `serve-prebuilt.ts` / `serve-prebuilt-paths.ts` | the image's prebuilt store; a boot that built anything logs `X_IMAGE_NOT_PREBUILT` † |
|
|
155
155
|
| `dev-*.ts` | `x dev` only: dashboard sources, traces, the N+1 ledger, watcher, reload, lock, port |
|
package/README.md
CHANGED
|
@@ -81,7 +81,8 @@ weigh measures the page a holder of that role is served. Any other refusal (a mi
|
|
|
81
81
|
|
|
82
82
|
While the export renders, `@ultimat3/seo`'s static seam is installed (`static-capture.ts`). Every
|
|
83
83
|
`responsiveImage()` candidate an exported document names is written to `/_img/<hash>-<w>.<ext>`
|
|
84
|
-
(`static-images.ts
|
|
84
|
+
(`static-images.ts`; the hash is of the source bytes, width, format and encoder — framework and Bun
|
|
85
|
+
version — so an upgrade that may re-encode renames the file rather than reuse an `immutable` URL) — a `src` the export lacks is `X_IMAGE_SOURCE_UNREADABLE`, an `avif` is
|
|
85
86
|
`X_IMAGE_UNSUPPORTED`. Every `og.capture` card is photographed from its exported page at 1200 x 630
|
|
86
87
|
into `/_og/<path>.png` over the CLI's own CDP driver (`static-cards.ts`); no such page is
|
|
87
88
|
`X_SEO_CARD_ROUTE_UNKNOWN`, no browser `X_SEO_CARD_BROWSER_MISSING`. `--no-capture` stamps the same
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultimat3/cli",
|
|
3
|
-
"version": "31.
|
|
3
|
+
"version": "31.15.0",
|
|
4
4
|
"description": "The `x` binary: new, dev, build, verify, generate, db, mcp, doctor, deploy",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ultimate",
|
|
@@ -53,34 +53,34 @@
|
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@babel/core": "^8.0.9",
|
|
56
|
-
"@ultimat3/action": "31.
|
|
57
|
-
"@ultimat3/admin": "31.
|
|
58
|
-
"@ultimat3/ai": "31.
|
|
59
|
-
"@ultimat3/auth": "31.
|
|
60
|
-
"@ultimat3/cache": "31.
|
|
61
|
-
"@ultimat3/core": "31.
|
|
62
|
-
"@ultimat3/db": "31.
|
|
63
|
-
"@ultimat3/entity": "31.
|
|
64
|
-
"@ultimat3/flags": "31.
|
|
65
|
-
"@ultimat3/http": "31.
|
|
66
|
-
"@ultimat3/i18n": "31.
|
|
67
|
-
"@ultimat3/jobs": "31.
|
|
68
|
-
"@ultimat3/mail": "31.
|
|
69
|
-
"@ultimat3/manifest": "31.
|
|
70
|
-
"@ultimat3/mcp": "31.
|
|
71
|
-
"@ultimat3/money": "31.
|
|
72
|
-
"@ultimat3/notify": "31.
|
|
73
|
-
"@ultimat3/policy": "31.
|
|
74
|
-
"@ultimat3/pwa": "31.
|
|
75
|
-
"@ultimat3/query": "31.
|
|
76
|
-
"@ultimat3/realtime": "31.
|
|
77
|
-
"@ultimat3/render": "31.
|
|
78
|
-
"@ultimat3/schema": "31.
|
|
79
|
-
"@ultimat3/scraping": "31.
|
|
80
|
-
"@ultimat3/seo": "31.
|
|
81
|
-
"@ultimat3/storage": "31.
|
|
82
|
-
"@ultimat3/testing": "31.
|
|
83
|
-
"@ultimat3/time": "31.
|
|
56
|
+
"@ultimat3/action": "31.15.0",
|
|
57
|
+
"@ultimat3/admin": "31.15.0",
|
|
58
|
+
"@ultimat3/ai": "31.15.0",
|
|
59
|
+
"@ultimat3/auth": "31.15.0",
|
|
60
|
+
"@ultimat3/cache": "31.15.0",
|
|
61
|
+
"@ultimat3/core": "31.15.0",
|
|
62
|
+
"@ultimat3/db": "31.15.0",
|
|
63
|
+
"@ultimat3/entity": "31.15.0",
|
|
64
|
+
"@ultimat3/flags": "31.15.0",
|
|
65
|
+
"@ultimat3/http": "31.15.0",
|
|
66
|
+
"@ultimat3/i18n": "31.15.0",
|
|
67
|
+
"@ultimat3/jobs": "31.15.0",
|
|
68
|
+
"@ultimat3/mail": "31.15.0",
|
|
69
|
+
"@ultimat3/manifest": "31.15.0",
|
|
70
|
+
"@ultimat3/mcp": "31.15.0",
|
|
71
|
+
"@ultimat3/money": "31.15.0",
|
|
72
|
+
"@ultimat3/notify": "31.15.0",
|
|
73
|
+
"@ultimat3/policy": "31.15.0",
|
|
74
|
+
"@ultimat3/pwa": "31.15.0",
|
|
75
|
+
"@ultimat3/query": "31.15.0",
|
|
76
|
+
"@ultimat3/realtime": "31.15.0",
|
|
77
|
+
"@ultimat3/render": "31.15.0",
|
|
78
|
+
"@ultimat3/schema": "31.15.0",
|
|
79
|
+
"@ultimat3/scraping": "31.15.0",
|
|
80
|
+
"@ultimat3/seo": "31.15.0",
|
|
81
|
+
"@ultimat3/storage": "31.15.0",
|
|
82
|
+
"@ultimat3/testing": "31.15.0",
|
|
83
|
+
"@ultimat3/time": "31.15.0",
|
|
84
84
|
"babel-preset-solid": "^1.9.16"
|
|
85
85
|
}
|
|
86
86
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Requests per route: how many fetches one document makes before it is whole — itself, every
|
|
2
|
+
// script file (`measureDocumentJs` counts those as it weighs them) and every stylesheet. Reported
|
|
3
|
+
// in the stats row beside the bytes, never budgeted: a ceiling is the app's declaration to make.
|
|
4
|
+
|
|
5
|
+
import { artifactPath, HREF_ATTR } from './budgets-scan';
|
|
6
|
+
|
|
7
|
+
/** A `<link>` whose `rel` list holds `stylesheet` — the one link a browser fetches to paint. */
|
|
8
|
+
const STYLESHEET_TAG = /<link\s[^>]*\brel="(?:[^"]*\s)?stylesheet(?:\s[^"]*)?"[^>]*>/g;
|
|
9
|
+
|
|
10
|
+
/** The requests one document makes, as the stats row records them. */
|
|
11
|
+
export interface RouteRequests {
|
|
12
|
+
readonly documents: 1;
|
|
13
|
+
/** Distinct same-origin script files fetched: entries, the chunks they import, framework files. */
|
|
14
|
+
readonly scripts: number;
|
|
15
|
+
/** Distinct same-origin stylesheets. */
|
|
16
|
+
readonly styles: number;
|
|
17
|
+
readonly total: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Distinct same-origin stylesheets `html` links, by the path a browser fetches — the unit
|
|
22
|
+
* `measureDocumentJs` dedupes scripts by. A cross-origin sheet is not this build's to count, and
|
|
23
|
+
* a `rel="preload"` of a sheet is the same fetch the stylesheet link then reuses.
|
|
24
|
+
*/
|
|
25
|
+
export function stylesheetRequests(html: string): number {
|
|
26
|
+
const paths = new Set<string>();
|
|
27
|
+
for (const match of html.matchAll(STYLESHEET_TAG)) {
|
|
28
|
+
const href = HREF_ATTR.exec(match[0])?.groups?.['href'];
|
|
29
|
+
const path = href === undefined ? undefined : artifactPath(href);
|
|
30
|
+
if (path !== undefined) paths.add(path);
|
|
31
|
+
}
|
|
32
|
+
return paths.size;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function routeRequests(scripts: number, styles: number): RouteRequests {
|
|
36
|
+
return { documents: 1, scripts, styles, total: 1 + scripts + styles };
|
|
37
|
+
}
|
package/src/budgets.ts
CHANGED
|
@@ -13,6 +13,8 @@ import type { Manifest, RouteFact } from '@ultimat3/manifest';
|
|
|
13
13
|
import { describePages, parseByteBudget, themeScriptBody } from '@ultimat3/render';
|
|
14
14
|
import type { ChargedFile } from './budgets-charged';
|
|
15
15
|
import { chargedClause, chargedMeta, heaviestFirst } from './budgets-charged';
|
|
16
|
+
import type { RouteRequests } from './budgets-requests';
|
|
17
|
+
import { routeRequests, stylesheetRequests } from './budgets-requests';
|
|
16
18
|
import {
|
|
17
19
|
artifactPath,
|
|
18
20
|
carriesJson,
|
|
@@ -55,6 +57,11 @@ export interface RouteStats {
|
|
|
55
57
|
readonly charged?: readonly ChargedFile[];
|
|
56
58
|
/** The app's inline script bytes inside `jsBytes` — the part no file in `charged` accounts for. */
|
|
57
59
|
readonly inlineJsBytes?: number;
|
|
60
|
+
/**
|
|
61
|
+
* The fetches the document makes — itself, its script files, its stylesheets. A measurement,
|
|
62
|
+
* never a budget. Optional for `frameworkJsBytes`' reason: an older row did not count them.
|
|
63
|
+
*/
|
|
64
|
+
readonly requests?: RouteRequests;
|
|
58
65
|
}
|
|
59
66
|
|
|
60
67
|
export interface BuildStats {
|
|
@@ -276,6 +283,10 @@ export interface MeasuredJs {
|
|
|
276
283
|
readonly inlineBytes: number;
|
|
277
284
|
/** Every APP `src=`/`data-x-entry=` module, so a finding can name the heaviest by file. */
|
|
278
285
|
readonly entries: readonly MeasuredEntry[];
|
|
286
|
+
/** Distinct same-origin script files the document fetches, framework files included. */
|
|
287
|
+
readonly scriptRequests: number;
|
|
288
|
+
/** Distinct same-origin stylesheets it links (`budgets-requests.ts`). */
|
|
289
|
+
readonly styleRequests: number;
|
|
279
290
|
}
|
|
280
291
|
|
|
281
292
|
/**
|
|
@@ -422,7 +433,14 @@ export async function measureDocumentJs(
|
|
|
422
433
|
const href = HREF_ATTR.exec(match[0])?.groups?.['href'];
|
|
423
434
|
if (href !== undefined) await weigh(href);
|
|
424
435
|
}
|
|
425
|
-
return {
|
|
436
|
+
return {
|
|
437
|
+
jsBytes,
|
|
438
|
+
frameworkBytes,
|
|
439
|
+
inlineBytes,
|
|
440
|
+
entries,
|
|
441
|
+
scriptRequests: fetched.size,
|
|
442
|
+
styleRequests: stylesheetRequests(html),
|
|
443
|
+
};
|
|
426
444
|
}
|
|
427
445
|
|
|
428
446
|
/**
|
|
@@ -441,6 +459,7 @@ export function routeStatsRow(
|
|
|
441
459
|
...(chain === undefined ? {} : { heaviestChain: chain }),
|
|
442
460
|
charged: heaviestFirst(measured.entries),
|
|
443
461
|
inlineJsBytes: measured.inlineBytes,
|
|
462
|
+
requests: routeRequests(measured.scriptRequests, measured.styleRequests),
|
|
444
463
|
};
|
|
445
464
|
}
|
|
446
465
|
|
package/src/dev-boot.ts
CHANGED
|
@@ -279,8 +279,8 @@ async function bootDev(
|
|
|
279
279
|
signInPath: await loadSignInPath(options.root),
|
|
280
280
|
// The same seam `serve.ts` passes: the app's own error page is a FILE under this root.
|
|
281
281
|
root: options.root,
|
|
282
|
-
// The `/_x` shell, the harness's frame
|
|
283
|
-
//
|
|
282
|
+
// The `/_x` shell, the harness's frame and the app's own error pages — the inline bodies this
|
|
283
|
+
// process serves; the app's surfaces, brand included, are hashed files `'self'` admits.
|
|
284
284
|
inlineStyles: [await devShellStyle(), FRAME_STYLE, ...inlineStyles],
|
|
285
285
|
inlineScripts: [
|
|
286
286
|
theme.cspSource,
|
package/src/dev-route-table.ts
CHANGED
|
@@ -78,8 +78,8 @@ export interface DevRouteTable {
|
|
|
78
78
|
/** The zone script (`time.detect`), admitted the same way — `undefined` when the app left it off. */
|
|
79
79
|
readonly zone: ZoneBoot | undefined;
|
|
80
80
|
/**
|
|
81
|
-
* Every inline `<style>` body these routes put in a document: the app's error pages'
|
|
82
|
-
*
|
|
81
|
+
* Every inline `<style>` body these routes put in a document: the app's error pages' — what
|
|
82
|
+
* `startRoles({ inlineStyles })` hashes into `style-src`. The brand rides the stylesheet.
|
|
83
83
|
*/
|
|
84
84
|
readonly inlineStyles: readonly string[];
|
|
85
85
|
/** Where the app's default MCP endpoint was mounted, or `null`. */
|
|
@@ -94,7 +94,8 @@ export async function devRouteTable(input: DevRouteTableInput): Promise<DevRoute
|
|
|
94
94
|
const pwa = await loadPwaArtifacts(input.root);
|
|
95
95
|
const theme = themeBoot(await loadThemeMode(input.root));
|
|
96
96
|
// Read at boot, like the theme mode: a save to the theme module is applied on the next `x dev`.
|
|
97
|
-
|
|
97
|
+
// Onto every surface stylesheet, before the first `styleBundle()` below.
|
|
98
|
+
await loadThemeBrand(input.root);
|
|
98
99
|
// `site.origin` and `seo.robots.disallow`: the absolute URLs every document and the sitemap carry.
|
|
99
100
|
const site = await loadSiteSettings(input.root);
|
|
100
101
|
const origin = publicOrigin(input.env, site);
|
|
@@ -114,10 +115,7 @@ export async function devRouteTable(input: DevRouteTableInput): Promise<DevRoute
|
|
|
114
115
|
client: declared.surfaces,
|
|
115
116
|
localeSegments: otherLocaleSegments(await appLocaleSet(input.root)),
|
|
116
117
|
});
|
|
117
|
-
const inlineStyles =
|
|
118
|
-
...(await errorPageStyleBodies(input.root)),
|
|
119
|
-
...(brand === undefined ? [] : [brand.style]),
|
|
120
|
-
];
|
|
118
|
+
const inlineStyles = await errorPageStyleBodies(input.root);
|
|
121
119
|
// Built once at boot and NOT rebuilt with the islands on a watcher tick: a service worker that
|
|
122
120
|
// changes under a page it controls is the update path, and one per keystroke exercises it per save.
|
|
123
121
|
const serviceWorker =
|
|
@@ -200,7 +198,6 @@ export async function devRouteTable(input: DevRouteTableInput): Promise<DevRoute
|
|
|
200
198
|
...adminMountRoutes({
|
|
201
199
|
buildId: input.buildId,
|
|
202
200
|
themeHead: theme.head,
|
|
203
|
-
...(brand === undefined ? {} : { brandHead: brand.head }),
|
|
204
201
|
...(origin === undefined ? {} : { origin }),
|
|
205
202
|
}),
|
|
206
203
|
...appRoutes({
|
|
@@ -214,7 +211,6 @@ export async function devRouteTable(input: DevRouteTableInput): Promise<DevRoute
|
|
|
214
211
|
persisted: sync.persisted,
|
|
215
212
|
...(navigation.head === undefined ? {} : { navigation: navigation.head }),
|
|
216
213
|
themeHead: theme.head,
|
|
217
|
-
...(brand === undefined ? {} : { brandHead: brand.head }),
|
|
218
214
|
...(speculation === undefined ? {} : { speculationHead: speculation.head }),
|
|
219
215
|
...(origin === undefined ? {} : { origin }),
|
|
220
216
|
...(pwa === undefined
|
package/src/document-options.ts
CHANGED
|
@@ -50,13 +50,6 @@ export interface DocumentOptions {
|
|
|
50
50
|
* decided by `app.config.ts`, which the boot read and the renderer cannot.
|
|
51
51
|
*/
|
|
52
52
|
readonly themeHead?: string;
|
|
53
|
-
/**
|
|
54
|
-
* The app's brand `<style>` from `theme-brand.ts`, or absent for an app with no
|
|
55
|
-
* `apps/web/shared/theme.ts`. Rendered AFTER the surface stylesheet `<link>`, never in the head
|
|
56
|
-
* block `themeHead` rides: the brand answers `theme.scss` at equal specificity, so only a later
|
|
57
|
-
* position in the cascade lets it win.
|
|
58
|
-
*/
|
|
59
|
-
readonly brandHead?: string;
|
|
60
53
|
/**
|
|
61
54
|
* The page's sync target — `pageSync(…).head` — rendered as render's `clientSyncTags` on every
|
|
62
55
|
* document this process serves. Principal-free, so a shareable document carries it too; absent
|
package/src/island-bundle.ts
CHANGED
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
// Bun ships no path API. `posix` does the specifier arithmetic (an app-relative route file is
|
|
21
21
|
// POSIX by construction), `join`/`basename` the filesystem side.
|
|
22
22
|
import { join, posix, relative, sep } from 'node:path';
|
|
23
|
+
import type { IslandsConfig } from '@ultimat3/core';
|
|
23
24
|
import { logger, renderThrowable } from '@ultimat3/core';
|
|
24
25
|
import { ISLAND_EXTENSION } from '@ultimat3/render';
|
|
25
26
|
import { loadAppConfig } from './app-config-load';
|
|
@@ -41,6 +42,7 @@ import { groupKey, readGroup, sweepOnce, writeGroup } from './island-group-cache
|
|
|
41
42
|
import { islandGroups } from './island-groups';
|
|
42
43
|
import { describeBuildError } from './island-identity';
|
|
43
44
|
import { linkOutputs } from './island-link';
|
|
45
|
+
import { refuseUnboundImports } from './island-link-check';
|
|
44
46
|
import { builtOutputs, entryChunks, ISLAND_BASE_PATH, sharedChunks } from './island-outputs';
|
|
45
47
|
import { frameworkDedupePlugins } from './island-package-dedupe';
|
|
46
48
|
import {
|
|
@@ -56,6 +58,8 @@ import { solidDedupePlugin } from './island-solid-dedupe';
|
|
|
56
58
|
import type { SourcePaths } from './island-sources';
|
|
57
59
|
import type { IslandStyles } from './island-styles';
|
|
58
60
|
import { islandStylesPlugin, stylesheetsOf } from './island-styles';
|
|
61
|
+
import type { Vendors } from './island-vendor';
|
|
62
|
+
import { loadingVendor, vendorBuilder, vendorExternalPlugin, vendorShared } from './island-vendor';
|
|
59
63
|
import { hasPathSegment } from './path-segments';
|
|
60
64
|
import { solidJsxPlugin } from './solid-loader';
|
|
61
65
|
|
|
@@ -169,6 +173,7 @@ async function buildAll(
|
|
|
169
173
|
const follows = new Set(files.filter((_, index) => realtime[index] === 'follows'));
|
|
170
174
|
const kinds = new Map(files.map((file, index) => [file, realtime[index]]));
|
|
171
175
|
const runtime = live[0] === undefined ? undefined : await runtimes(live[0]);
|
|
176
|
+
const vendor = context.vendors === undefined ? undefined : await context.vendors();
|
|
172
177
|
const entrypoints = files.map((file, index) =>
|
|
173
178
|
realtime[index] !== undefined ? realtimeIslandEntry(file) : join(root, file),
|
|
174
179
|
);
|
|
@@ -200,6 +205,8 @@ async function buildAll(
|
|
|
200
205
|
// gets the same rule (`island-package-dedupe.ts`): a nested copy is a second module where no
|
|
201
206
|
// symlink folds it, which is every `file:` install on Windows.
|
|
202
207
|
plugins: [
|
|
208
|
+
// Ahead of everything: Solid itself is never read into an island (`island-vendor.ts`).
|
|
209
|
+
...(vendor === undefined ? [] : [vendorExternalPlugin(vendor)]),
|
|
203
210
|
...(runtime === undefined
|
|
204
211
|
? []
|
|
205
212
|
: [islandRealtimePlugin(root, runtime, follows, live.length === files.length)]),
|
|
@@ -250,22 +257,28 @@ async function buildAll(
|
|
|
250
257
|
await refuseDuplicatedModules(files.join(', '), built.metafile, context.io);
|
|
251
258
|
const sources = new Map<string, SourcePaths>();
|
|
252
259
|
const linked = linkOutputs(await builtOutputs(root, files, built.outputs, sources));
|
|
253
|
-
const
|
|
260
|
+
const entries = loadingRuntime(entryChunks(files, linked, sources), live, runtime).map(
|
|
254
261
|
(chunk): IslandChunk => {
|
|
255
262
|
const kind = kinds.get(chunk.file);
|
|
256
263
|
return kind === undefined ? chunk : { ...chunk, realtime: kind };
|
|
257
264
|
},
|
|
258
265
|
);
|
|
259
|
-
const shared = sharedChunks(
|
|
266
|
+
const shared = sharedChunks(entries, linked, sources);
|
|
267
|
+
const chunks = loadingVendor(entries, shared, vendor);
|
|
260
268
|
const read = Object.keys(built.metafile.inputs);
|
|
261
269
|
const stylesheets = stylesheetsOf(read);
|
|
262
|
-
// The bundler's inputs, the runtime's, and every Sass partial a sheet `@use`s: a
|
|
263
|
-
// the sheet's class hashes and is read by the Sass compiler, never by the bundler.
|
|
270
|
+
// The bundler's inputs, the runtime's, the vendor's, and every Sass partial a sheet `@use`s: a
|
|
271
|
+
// partial moves the sheet's class hashes and is read by the Sass compiler, never by the bundler.
|
|
264
272
|
const partials = context.styles.dependenciesOf(stylesheets);
|
|
265
|
-
const readFiles = [
|
|
273
|
+
const readFiles = [
|
|
274
|
+
...(await inputFiles(read)),
|
|
275
|
+
...(runtime?.inputs ?? []),
|
|
276
|
+
...(vendor?.inputs ?? []),
|
|
277
|
+
...partials,
|
|
278
|
+
];
|
|
266
279
|
return {
|
|
267
280
|
chunks,
|
|
268
|
-
shared: [...shared, ...runtimeShared(runtime, live)],
|
|
281
|
+
shared: [...shared, ...runtimeShared(runtime, live), ...vendorShared(vendor, chunks)],
|
|
269
282
|
inputs: [...new Set(readFiles)].sort(),
|
|
270
283
|
stylesheets,
|
|
271
284
|
};
|
|
@@ -303,6 +316,8 @@ interface BuildContext {
|
|
|
303
316
|
readonly styles: IslandStyles;
|
|
304
317
|
/** One realpath per file per call, however many groups' metafiles name it. */
|
|
305
318
|
readonly io: ModuleIdentityIo;
|
|
319
|
+
/** Solid as one shared output (`island-vendor.ts`); `undefined` bundles it into each build. */
|
|
320
|
+
readonly vendors: Vendors | undefined;
|
|
306
321
|
}
|
|
307
322
|
|
|
308
323
|
export interface BuildIslandsOptions {
|
|
@@ -336,11 +351,19 @@ export interface BuildIslandsOptions {
|
|
|
336
351
|
* the registry is read as it stands: the caller loaded the app first.
|
|
337
352
|
*/
|
|
338
353
|
readonly persists?: () => Promise<boolean | undefined>;
|
|
354
|
+
/**
|
|
355
|
+
* Solid as ONE shared output every island imports (`island-vendor.ts`), off by default. Measured
|
|
356
|
+
* As of 2026-11-12 (Bun 1.4.4, solid-js 1.9.17): each island inlines a tree-shaken ~14 kB of
|
|
357
|
+
* Solid, the whole vendor is 48,083 B, so every Solid route of the three tracked apps grew
|
|
358
|
+
* +33,572…+38,769 B with it on; it pays only where a page renders four or more Solid islands
|
|
359
|
+
* that are built apart.
|
|
360
|
+
*/
|
|
361
|
+
readonly vendorSolid?: boolean;
|
|
339
362
|
}
|
|
340
363
|
|
|
341
|
-
/** `islands
|
|
342
|
-
|
|
343
|
-
return (await loadAppConfig(root))?.islands
|
|
364
|
+
/** The `islands` block off the one loader (`app-config-load.ts`) — both off with no config file. */
|
|
365
|
+
async function loadIslandsConfig(root: string): Promise<IslandsConfig> {
|
|
366
|
+
return (await loadAppConfig(root))?.islands ?? { sharedChunks: false, vendorSolid: false };
|
|
344
367
|
}
|
|
345
368
|
|
|
346
369
|
/** Build every island in the app. An app with none returns an empty bundle and costs one glob. */
|
|
@@ -355,10 +378,16 @@ export async function buildIslands(
|
|
|
355
378
|
// an empty bundle here would surface two steps later, as a chunk table with no entry for a file
|
|
356
379
|
// the caller can see on disk.
|
|
357
380
|
if (only !== undefined && files.length === 0) throw onlyMissing(only, discovered);
|
|
381
|
+
// Read only where an option leaves a question open: an app with no islands costs one glob.
|
|
382
|
+
const asks =
|
|
383
|
+
files.length > 0 && (options.sharedChunks === undefined || options.vendorSolid === undefined);
|
|
384
|
+
const configured = asks ? await loadIslandsConfig(root) : undefined;
|
|
385
|
+
const vendorSolid = files.length > 0 && (options.vendorSolid ?? configured?.vendorSolid ?? false);
|
|
358
386
|
const context: BuildContext = {
|
|
359
387
|
runtimes: runtimeBuilder(root, ISLAND_BASE_PATH),
|
|
360
388
|
styles: islandStylesPlugin(),
|
|
361
389
|
io: memoizedIo(hostIo()),
|
|
390
|
+
vendors: vendorSolid ? vendorBuilder(root, ISLAND_BASE_PATH) : undefined,
|
|
362
391
|
};
|
|
363
392
|
let asked: Promise<boolean | undefined> | undefined;
|
|
364
393
|
const persistsOnce = (): Promise<boolean | undefined> => {
|
|
@@ -369,7 +398,8 @@ export async function buildIslands(
|
|
|
369
398
|
// build; every other island is alone, splitting off, self-contained but for the page runtime —
|
|
370
399
|
// the ONE file every realtime island loads, counted once however many load it.
|
|
371
400
|
// `islands.sharedChunks` is the one group of every island, split as it always was.
|
|
372
|
-
const everyIsland =
|
|
401
|
+
const everyIsland =
|
|
402
|
+
files.length > 0 && (options.sharedChunks ?? configured?.sharedChunks ?? false);
|
|
373
403
|
const groups = everyIsland ? [files] : files.length === 0 ? [] : await islandGroups(root, files);
|
|
374
404
|
const reuse = options.reuse ?? true;
|
|
375
405
|
const cache = {
|
|
@@ -390,7 +420,13 @@ export async function buildIslands(
|
|
|
390
420
|
);
|
|
391
421
|
const persists = reaches.includes(true) ? await persistsOnce() : undefined;
|
|
392
422
|
if (!reuse) return buildAll(root, group, splitting, context, persists);
|
|
393
|
-
const key = groupKey({
|
|
423
|
+
const key = groupKey({
|
|
424
|
+
group,
|
|
425
|
+
splitting,
|
|
426
|
+
environment: cache.environment,
|
|
427
|
+
persists,
|
|
428
|
+
vendor: vendorSolid,
|
|
429
|
+
});
|
|
394
430
|
const hit = await readGroup(root, key, cache.digestOf, cache.listingOf);
|
|
395
431
|
if (hit !== undefined) return hit;
|
|
396
432
|
// The wall clock as the filesystem stamps an mtime — never `Date.now()`, which a test may freeze.
|
|
@@ -408,7 +444,11 @@ export async function buildIslands(
|
|
|
408
444
|
};
|
|
409
445
|
if (reuse) await sweepOnce(root);
|
|
410
446
|
const width = navigator.hardwareConcurrency;
|
|
411
|
-
|
|
447
|
+
const [chunks, shared] = mergeBuilds(await boundedMap(groups, width, build));
|
|
448
|
+
// Over the MERGED bundle: groups come from a cache or a fresh build, the runtime and the vendor
|
|
449
|
+
// from builds of their own, so this is the one place every link of the page's files is in view.
|
|
450
|
+
refuseUnboundImports([...chunks, ...shared.map((one) => ({ ...one, file: one.importers[0] }))]);
|
|
451
|
+
return islandBundle(chunks, shared);
|
|
412
452
|
}
|
|
413
453
|
|
|
414
454
|
type GroupBuild = Pick<GroupOutput, 'chunks' | 'shared'>;
|
package/src/island-disposer.ts
CHANGED
|
@@ -107,7 +107,7 @@ export function islandDisposerFindings(files: readonly SourceFile[]): readonly F
|
|
|
107
107
|
{
|
|
108
108
|
code: 'X_ISLAND_DISPOSER_MISSING',
|
|
109
109
|
cause: `${path}'s mount() ${why}, so the client router has nothing to call when it navigates away and the island's listeners, hotkeys and live reads stay registered`,
|
|
110
|
-
fix: `x verify --only boundaries --json # in ${commentSafe(path)}, end mount() with return render(() => <Island {...props} />,
|
|
110
|
+
fix: `x verify --only boundaries --json # in ${commentSafe(path)}, end mount() with return mountOver(el, (root) => render(() => <Island {...props} />, root)) — Solid's disposer, which the router calls (mountOver from @ultimat3/render/client)`,
|
|
111
111
|
docs: ERROR_DOCS_URL,
|
|
112
112
|
at: path,
|
|
113
113
|
},
|
|
@@ -77,6 +77,8 @@ export function groupKey(parts: {
|
|
|
77
77
|
readonly splitting: boolean;
|
|
78
78
|
readonly environment: string;
|
|
79
79
|
readonly persists: boolean | undefined;
|
|
80
|
+
/** Solid as one shared output (`island-vendor.ts`): other bytes, so another entry. */
|
|
81
|
+
readonly vendor?: boolean;
|
|
80
82
|
}): string {
|
|
81
83
|
return contentHash(
|
|
82
84
|
JSON.stringify([
|
|
@@ -87,6 +89,8 @@ export function groupKey(parts: {
|
|
|
87
89
|
parts.group,
|
|
88
90
|
parts.splitting,
|
|
89
91
|
parts.persists ?? null,
|
|
92
|
+
// Appended only when on, so every entry written before the vendor existed keeps its key.
|
|
93
|
+
...(parts.vendor === true ? ['vendor-solid'] : []),
|
|
90
94
|
]),
|
|
91
95
|
);
|
|
92
96
|
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// The post-build smoke #1075 asked for: every name an island output imports from another output
|
|
2
|
+
// of the bundle is a name that output exports. Groups come out of a cache, a store or a fresh
|
|
3
|
+
// build, and the vendor and page runtime are built apart — a binding that names nothing would
|
|
4
|
+
// fail in the browser as a `SyntaxError` on a blank island; here it fails the build, by file.
|
|
5
|
+
|
|
6
|
+
// why: Bun ships no path API; `basename` of a relative specifier.
|
|
7
|
+
import { posix } from 'node:path';
|
|
8
|
+
import { IslandBuildFailedError } from './errors';
|
|
9
|
+
|
|
10
|
+
/** One output as the check reads it: where it is served and what it is. */
|
|
11
|
+
export interface LinkedAsset {
|
|
12
|
+
readonly url: string;
|
|
13
|
+
readonly code: string;
|
|
14
|
+
/** The island source a refusal names — the entry's own, or a shared chunk's first importer. */
|
|
15
|
+
readonly file?: string | undefined;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** A static `import{a as b,c}from"./x.js"` as Bun's minifier writes one. */
|
|
19
|
+
const NAMED_IMPORT = /import\s*\{([^}]*)\}\s*from\s*"(\.\/[^"]+)"/g;
|
|
20
|
+
|
|
21
|
+
/** `a as b` → `a`; `default as b` → `default`; a quoted name keeps its spelling. */
|
|
22
|
+
const importedName = (binding: string): string => {
|
|
23
|
+
const [name = ''] = binding.trim().split(/\s+as\s+/);
|
|
24
|
+
return name.startsWith('"') ? (JSON.parse(name) as string) : name;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export interface UnboundImport {
|
|
28
|
+
readonly importer: string;
|
|
29
|
+
readonly file: string | undefined;
|
|
30
|
+
readonly target: string;
|
|
31
|
+
readonly name: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Every imported name no sibling output exports, in the order found; empty when all bind. */
|
|
35
|
+
export function unboundImports(assets: readonly LinkedAsset[]): readonly UnboundImport[] {
|
|
36
|
+
const byName = new Map(assets.map((one) => [posix.basename(one.url), one]));
|
|
37
|
+
const exportsOf = new Map<string, ReadonlySet<string>>();
|
|
38
|
+
const transpiler = new Bun.Transpiler({ loader: 'js' });
|
|
39
|
+
const exported = (asset: LinkedAsset): ReadonlySet<string> => {
|
|
40
|
+
let known = exportsOf.get(asset.url);
|
|
41
|
+
if (known === undefined) {
|
|
42
|
+
known = new Set(transpiler.scan(asset.code).exports);
|
|
43
|
+
exportsOf.set(asset.url, known);
|
|
44
|
+
}
|
|
45
|
+
return known;
|
|
46
|
+
};
|
|
47
|
+
const unbound: UnboundImport[] = [];
|
|
48
|
+
for (const asset of assets) {
|
|
49
|
+
for (const match of asset.code.matchAll(NAMED_IMPORT)) {
|
|
50
|
+
const target = byName.get(posix.basename(match[2] ?? ''));
|
|
51
|
+
// A specifier naming no output of the bundle is not this check's: nothing it links to.
|
|
52
|
+
if (target === undefined) continue;
|
|
53
|
+
const names = exported(target);
|
|
54
|
+
for (const binding of (match[1] ?? '').split(',')) {
|
|
55
|
+
const name = importedName(binding);
|
|
56
|
+
if (name !== '' && !names.has(name)) {
|
|
57
|
+
unbound.push({ importer: asset.url, file: asset.file, target: target.url, name });
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return unbound;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Refuses a bundle whose outputs do not link, naming the first import that binds nothing. */
|
|
66
|
+
export function refuseUnboundImports(assets: readonly LinkedAsset[]): void {
|
|
67
|
+
const [first] = unboundImports(assets);
|
|
68
|
+
if (first === undefined) return;
|
|
69
|
+
throw new IslandBuildFailedError({
|
|
70
|
+
file: first.file ?? first.importer,
|
|
71
|
+
logs: `${first.importer} imports ${first.name} from ${first.target}, which exports no such name, so the island would fail to link in the browser — clear the island cache with rm -rf .x/cache/islands and build again`,
|
|
72
|
+
});
|
|
73
|
+
}
|