brumate 0.4.4 → 0.5.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/dist/{boot-D3NjfyUX.d.ts → boot-Difa0qdg.d.ts} +2 -8
- package/dist/cli.js +2 -2
- package/dist/{client-DNva05jp.d.ts → client-DvsU9qxG.d.ts} +107 -23
- package/dist/{client-iZ9a1Nut.js → client-glvRglTB.js} +990 -369
- package/dist/client-glvRglTB.js.map +1 -0
- package/dist/{defer-DP7dMS2y.js → defer-CNYYG-A5.js} +2 -2
- package/dist/{defer-DP7dMS2y.js.map → defer-CNYYG-A5.js.map} +1 -1
- package/dist/{devtools-BJB_MMeL.js → devtools-D8EioKXs.js} +4 -4
- package/dist/{devtools-BJB_MMeL.js.map → devtools-D8EioKXs.js.map} +1 -1
- package/dist/{devtools-panel-CUV6A4ZE.js → devtools-panel-BKmBqkau.js} +2 -2
- package/dist/{devtools-panel-CUV6A4ZE.js.map → devtools-panel-BKmBqkau.js.map} +1 -1
- package/dist/{features-CHY5Ekku.js → features-D5kLyihb.js} +19 -2
- package/dist/features-D5kLyihb.js.map +1 -0
- package/dist/{files-BZRjz9Mx.js → files-ClQJlDcB.js} +2 -2
- package/dist/{files-BZRjz9Mx.js.map → files-ClQJlDcB.js.map} +1 -1
- package/dist/index.d.ts +1 -8
- package/dist/index.js +1 -1
- package/dist/{inspect-BLOdfj7o.js → inspect-B8i6R3mZ.js} +876 -132
- package/dist/inspect-B8i6R3mZ.js.map +1 -0
- package/dist/{loader-CheV6t0N.js → loader-DB0i9MwD.js} +4 -4
- package/dist/{loader-CheV6t0N.js.map → loader-DB0i9MwD.js.map} +1 -1
- package/dist/{navigate-CfOr-TRF.js → navigate-BcV1qkkx.js} +2 -2
- package/dist/navigate-BcV1qkkx.js.map +1 -0
- package/dist/{produce-DS-dQaUX.js → produce-Cq6KKi7b.js} +2 -2
- package/dist/{produce-DS-dQaUX.js.map → produce-Cq6KKi7b.js.map} +1 -1
- package/dist/{rpc-DvTwGfL_.js → rpc-BHlxmeWe.js} +5 -5
- package/dist/rpc-BHlxmeWe.js.map +1 -0
- package/dist/runtime/bundles.d.ts +9 -0
- package/dist/runtime/bundles.js +60 -0
- package/dist/runtime/bundles.js.map +1 -0
- package/dist/runtime/client.d.ts +2 -2
- package/dist/runtime/client.js +3 -3
- package/dist/runtime/devtools.d.ts +1 -1
- package/dist/runtime/devtools.js +1 -1
- package/dist/runtime/hot.d.ts +1 -1
- package/dist/runtime/loader.d.ts +2 -2
- package/dist/runtime/loader.js +2 -2
- package/dist/runtime/server.d.ts +3 -3
- package/dist/runtime/server.js +4 -4
- package/dist/runtime/static-loader.d.ts +2 -2
- package/dist/runtime/static-loader.js +1 -1
- package/dist/runtime/testing.d.ts +2 -2
- package/dist/runtime/testing.js +2 -2
- package/dist/{server-BXMH3Z9T.d.ts → server-CAwIqrXl.d.ts} +44 -5
- package/dist/{server-O_rC-RRL.js → server-Doy5HR7r.js} +106 -17
- package/dist/server-Doy5HR7r.js.map +1 -0
- package/dist/{static-loader-BiUaZaag.d.ts → static-loader-9Nc1GvF0.d.ts} +2 -2
- package/dist/{static-loader-BLJYvTKc.js → static-loader-D0ARlMxM.js} +3 -26
- package/dist/static-loader-D0ARlMxM.js.map +1 -0
- package/dist/{stream-JGRPr7u5.js → stream-BdhzvPQO.js} +2 -2
- package/dist/{stream-JGRPr7u5.js.map → stream-BdhzvPQO.js.map} +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +129 -51
- package/dist/vite.js.map +1 -1
- package/package.json +5 -1
- package/skills/brumate/references/errors.md +19 -5
- package/dist/client-iZ9a1Nut.js.map +0 -1
- package/dist/features-CHY5Ekku.js.map +0 -1
- package/dist/inspect-BLOdfj7o.js.map +0 -1
- package/dist/navigate-CfOr-TRF.js.map +0 -1
- package/dist/rpc-DvTwGfL_.js.map +0 -1
- package/dist/server-O_rC-RRL.js.map +0 -1
- package/dist/static-loader-BLJYvTKc.js.map +0 -1
package/dist/vite.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { A as analyzeProject, B as getLocation, C as isReactiveModule, E as originalPosition, I as parse, J as walk, M as importSource, N as importedComponents, O as entryClasses, P as resolveRelative, R as forEachNode, T as builtin, U as analyze, _ as functionId, a as scopeLabel, b as SHARED_QUERY, f as instanceScope, i as report, k as refreshedNames, n as formatReport, p as slotIndex, q as resolveMacros, s as compile, t as anchorLabel, v as getComponentName, w as resolveFromDisk, x as generateShared, y as hash } from "./inspect-
|
|
1
|
+
import { A as analyzeProject, B as getLocation, C as isReactiveModule, E as originalPosition, I as parse, J as walk, M as importSource, N as importedComponents, O as entryClasses, P as resolveRelative, R as forEachNode, T as builtin, U as analyze, _ as functionId, a as scopeLabel, b as SHARED_QUERY, f as instanceScope, i as report, k as refreshedNames, n as formatReport, p as slotIndex, q as resolveMacros, s as compile, t as anchorLabel, v as getComponentName, w as resolveFromDisk, x as generateShared, y as hash } from "./inspect-B8i6R3mZ.js";
|
|
2
2
|
import { s as toNodeHeaders } from "./cookies-Cnbf4w-S.js";
|
|
3
3
|
import { t as LOGO } from "./logo-DQ_OYhBi.js";
|
|
4
|
-
import { _ as reachableFiles, a as findServerFiles, c as hasServerMiddleware, d as serverExports, f as serverModule, g as packageFileName, h as findPackages, i as findScripts, l as hasUseServer, m as findPackage, n as defaultExclude, o as findPackageServerFile, p as serverStubs, r as findFiles, u as isScriptFile, v as resolveComponentPackage } from "./files-
|
|
4
|
+
import { _ as reachableFiles, a as findServerFiles, c as hasServerMiddleware, d as serverExports, f as serverModule, g as packageFileName, h as findPackages, i as findScripts, l as hasUseServer, m as findPackage, n as defaultExclude, o as findPackageServerFile, p as serverStubs, r as findFiles, u as isScriptFile, v as resolveComponentPackage } from "./files-ClQJlDcB.js";
|
|
5
5
|
import { parseSync } from "oxc-parser";
|
|
6
6
|
import { createHash } from "node:crypto";
|
|
7
7
|
import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, writeFileSync } from "node:fs";
|
|
@@ -121,7 +121,14 @@ function noFeatures() {
|
|
|
121
121
|
blocks: false,
|
|
122
122
|
listeners: false,
|
|
123
123
|
actions: false,
|
|
124
|
-
clientHTML: false
|
|
124
|
+
clientHTML: false,
|
|
125
|
+
tries: false,
|
|
126
|
+
fields: false,
|
|
127
|
+
windows: false,
|
|
128
|
+
dynamic: false,
|
|
129
|
+
routes: false,
|
|
130
|
+
loading: false,
|
|
131
|
+
rootWait: false
|
|
125
132
|
};
|
|
126
133
|
}
|
|
127
134
|
/** Every feature, for a build that compiles components in the browser. */
|
|
@@ -147,7 +154,14 @@ function getFeatures(result) {
|
|
|
147
154
|
blocks: /\bb-(?:client|defer)\b/.test(all),
|
|
148
155
|
listeners: /\bb-listen\b/.test(all),
|
|
149
156
|
actions: /\$\$b\.action\(/.test(all),
|
|
150
|
-
clientHTML: /\breturn \$\$html;/.test(client)
|
|
157
|
+
clientHTML: /\breturn \$\$html;/.test(client),
|
|
158
|
+
tries: /\$\$b\.caught\(/.test(result.server) || /\bexport const t = /.test(client),
|
|
159
|
+
fields: /=\$bind#|=\$set:|\$\$b\.binding\(/.test(all),
|
|
160
|
+
windows: /\$\$b\.windowList\(/.test(client),
|
|
161
|
+
dynamic: /\$\$b\.dynamic(?:Nodes)?\(/.test(client),
|
|
162
|
+
routes: /\b(?:routeContext|navigationContext)\b/.test(all),
|
|
163
|
+
loading: /\$\$b\.loading\(/.test(client),
|
|
164
|
+
rootWait: /\$\$b\.wait\(/.test(client)
|
|
151
165
|
};
|
|
152
166
|
}
|
|
153
167
|
/** The features of several components together. */
|
|
@@ -163,6 +177,13 @@ function joinFeatures(all) {
|
|
|
163
177
|
joined.listeners ||= features.listeners;
|
|
164
178
|
joined.actions ||= features.actions;
|
|
165
179
|
joined.clientHTML ||= features.clientHTML;
|
|
180
|
+
joined.tries ||= features.tries;
|
|
181
|
+
joined.fields ||= features.fields;
|
|
182
|
+
joined.windows ||= features.windows;
|
|
183
|
+
joined.dynamic ||= features.dynamic;
|
|
184
|
+
joined.routes ||= features.routes;
|
|
185
|
+
joined.loading ||= features.loading;
|
|
186
|
+
joined.rootWait ||= features.rootWait;
|
|
166
187
|
}
|
|
167
188
|
return joined;
|
|
168
189
|
}
|
|
@@ -176,7 +197,14 @@ const GLOBALS = {
|
|
|
176
197
|
blocks: "__BRUMATE_HAS_BLOCKS__",
|
|
177
198
|
listeners: "__BRUMATE_HAS_LISTENERS__",
|
|
178
199
|
actions: "__BRUMATE_HAS_ACTIONS__",
|
|
179
|
-
clientHTML: "__BRUMATE_HAS_CLIENT_HTML__"
|
|
200
|
+
clientHTML: "__BRUMATE_HAS_CLIENT_HTML__",
|
|
201
|
+
tries: "__BRUMATE_HAS_TRIES__",
|
|
202
|
+
fields: "__BRUMATE_HAS_FIELDS__",
|
|
203
|
+
windows: "__BRUMATE_HAS_WINDOWS__",
|
|
204
|
+
dynamic: "__BRUMATE_HAS_DYNAMIC__",
|
|
205
|
+
routes: "__BRUMATE_HAS_ROUTES__",
|
|
206
|
+
loading: "__BRUMATE_HAS_LOADING__",
|
|
207
|
+
rootWait: "__BRUMATE_HAS_ROOT_WAIT__"
|
|
180
208
|
};
|
|
181
209
|
/** True for code that reads a feature, such as the core. */
|
|
182
210
|
function readsFeatures(code) {
|
|
@@ -1719,8 +1747,18 @@ const START = "virtual:brumate/start";
|
|
|
1719
1747
|
const MANIFEST = "virtual:brumate/manifest";
|
|
1720
1748
|
/** `virtual:brumate/bundle/<id>` imports the client modules of a root component and those it renders. */
|
|
1721
1749
|
const BUNDLE = "virtual:brumate/bundle/";
|
|
1750
|
+
/** `virtual:brumate/bundles` imports every bundle. Nothing loads it. See `manifest`. */
|
|
1751
|
+
const BUNDLES = "virtual:brumate/bundles";
|
|
1722
1752
|
/** Exports `functions` and `handle(request)` for server function calls. */
|
|
1723
1753
|
const SERVER = "virtual:brumate/server";
|
|
1754
|
+
/**
|
|
1755
|
+
* Sets the bundles of the client build as the default of each render in a server build. The
|
|
1756
|
+
* server version of each component imports it, so a server that calls `render()` itself names
|
|
1757
|
+
* the bundles of its pages too.
|
|
1758
|
+
*/
|
|
1759
|
+
const CLIENT_BUNDLES = "virtual:brumate/client-bundles";
|
|
1760
|
+
/** A script that names a route context, or exports all of `brumate/context`. */
|
|
1761
|
+
const ROUTE_CONTEXTS = /\b(?:routeContext|navigationContext)\b|export\s*\*\s*from\s*['"]brumate\/context['"]/;
|
|
1724
1762
|
/** Exports `routes` and `handle(request, options)` for the files in the routes directory. */
|
|
1725
1763
|
const ROUTES = "virtual:brumate/routes";
|
|
1726
1764
|
/** The entry of the server build that prerendering renders with. */
|
|
@@ -2103,6 +2141,15 @@ function brumate(options = {}) {
|
|
|
2103
2141
|
break;
|
|
2104
2142
|
}
|
|
2105
2143
|
features.lateMarkup ||= options.navigate !== false || loading;
|
|
2144
|
+
features.routes ||= options.navigate !== false;
|
|
2145
|
+
if (!features.routes) {
|
|
2146
|
+
const own = path.resolve(import.meta.dirname, "..").split(path.sep).join("/");
|
|
2147
|
+
const texts = await inBatches([.../* @__PURE__ */ new Set([...await findScripts(root, exclude), ...reachable()])].filter((file) => !file.startsWith(`${own}/dist/`) && !file.startsWith(`${own}/src/`)), (file) => readFile(file, "utf8").catch(() => ""));
|
|
2148
|
+
for (const text of texts) if (ROUTE_CONTEXTS.test(text)) {
|
|
2149
|
+
features.routes = true;
|
|
2150
|
+
break;
|
|
2151
|
+
}
|
|
2152
|
+
}
|
|
2106
2153
|
counted = seen;
|
|
2107
2154
|
knownFeatures = features;
|
|
2108
2155
|
return features;
|
|
@@ -2251,6 +2298,10 @@ function brumate(options = {}) {
|
|
|
2251
2298
|
"};"
|
|
2252
2299
|
].join("\n");
|
|
2253
2300
|
}
|
|
2301
|
+
/** The hints of the client build of this process, for a server build that follows it. */
|
|
2302
|
+
let builtHints;
|
|
2303
|
+
/** The IDs of the components in each bundle of the client build, by root, for `hints.json`. */
|
|
2304
|
+
const bundleMembers = /* @__PURE__ */ new Map();
|
|
2254
2305
|
async function manifest() {
|
|
2255
2306
|
const list = [...files];
|
|
2256
2307
|
const needed = await inBatches(list, async ([, file]) => isServe || (await compileFile(file)).result.clientCode);
|
|
@@ -2260,45 +2311,19 @@ function brumate(options = {}) {
|
|
|
2260
2311
|
const keptFiles = /* @__PURE__ */ new Set();
|
|
2261
2312
|
for (const [, file] of kept) keptFiles.add(file);
|
|
2262
2313
|
const groups = await bundles(keptFiles);
|
|
2263
|
-
|
|
2264
|
-
for (const [root, members] of groups)
|
|
2265
|
-
const
|
|
2266
|
-
|
|
2314
|
+
bundleMembers.clear();
|
|
2315
|
+
for (const [root, members] of groups) {
|
|
2316
|
+
const ids = [];
|
|
2317
|
+
for (const member of members) {
|
|
2318
|
+
const id = findComponentId(member);
|
|
2319
|
+
if (id !== void 0) ids.push(id);
|
|
2320
|
+
}
|
|
2321
|
+
bundleMembers.set(root, ids);
|
|
2267
2322
|
}
|
|
2268
|
-
for (const [id, root] of owners) if (id === root) owners.delete(id);
|
|
2269
|
-
const bundleLines = [];
|
|
2270
|
-
for (const root of groups.keys()) bundleLines.push(` ${JSON.stringify(root)}: () => import(${JSON.stringify(`${BUNDLE}${root}`)}),`);
|
|
2271
2323
|
return [
|
|
2272
|
-
"
|
|
2273
|
-
|
|
2274
|
-
"};"
|
|
2275
|
-
`const owners = ${JSON.stringify(Object.fromEntries(owners))};`,
|
|
2276
|
-
"const loaded = new Map();",
|
|
2277
|
-
"const pending = new Map();",
|
|
2278
|
-
"/** Loads the bundle of a root component of the page. Undefined for a component that is not a root. */",
|
|
2279
|
-
"export function loadBundle(root) {",
|
|
2280
|
-
" let promise = pending.get(root);",
|
|
2281
|
-
" if (!promise && bundles[root]) {",
|
|
2282
|
-
" promise = bundles[root]().then((bundle) => {",
|
|
2283
|
-
" for (const [id, module] of Object.entries(bundle.modules)) {",
|
|
2284
|
-
" loaded.set(id, module);",
|
|
2285
|
-
" }",
|
|
2286
|
-
" });",
|
|
2287
|
-
" pending.set(root, promise);",
|
|
2288
|
-
" promise.catch(() => pending.delete(root));",
|
|
2289
|
-
" }",
|
|
2290
|
-
" return promise;",
|
|
2291
|
-
"}",
|
|
2292
|
-
"/** The client module of a component, from the bundles of the page, or else from a bundle that holds it. */",
|
|
2293
|
-
"export function load(id) {",
|
|
2294
|
-
" if (loaded.has(id)) {",
|
|
2295
|
-
" return Promise.resolve(loaded.get(id));",
|
|
2296
|
-
" }",
|
|
2297
|
-
" const waiting = [...pending.values()];",
|
|
2298
|
-
" const root = owners[id] ?? (bundles[id] && id);",
|
|
2299
|
-
" const owner = () => (loaded.has(id) || !root ? loaded.get(id) : loadBundle(root).then(() => loaded.get(id)));",
|
|
2300
|
-
" return waiting.length > 0 ? Promise.allSettled(waiting).then(owner) : root ? owner() : undefined;",
|
|
2301
|
-
"}"
|
|
2324
|
+
"import { load } from 'brumate/bundles';",
|
|
2325
|
+
`load.all = () => import(${JSON.stringify(BUNDLES)});`,
|
|
2326
|
+
"export { load };"
|
|
2302
2327
|
].join("\n");
|
|
2303
2328
|
}
|
|
2304
2329
|
const entries = [];
|
|
@@ -2411,6 +2436,7 @@ function brumate(options = {}) {
|
|
|
2411
2436
|
* or none before a client build or in development.
|
|
2412
2437
|
*/
|
|
2413
2438
|
function clientHints() {
|
|
2439
|
+
if (builtHints && !isServe) return builtHints;
|
|
2414
2440
|
const file = path.join(clientBuildDirectory(root, options.prerender), HINTS_FILE);
|
|
2415
2441
|
if (isServe || !existsSync(file)) return {
|
|
2416
2442
|
all: [],
|
|
@@ -2425,12 +2451,15 @@ function brumate(options = {}) {
|
|
|
2425
2451
|
/** The route tree module. A DOM test gets the server version of each component in it. */
|
|
2426
2452
|
function routeTree(server = false) {
|
|
2427
2453
|
const env = envFile();
|
|
2428
|
-
const
|
|
2454
|
+
const hints = clientHints();
|
|
2455
|
+
const code = routeModule(currentRoutes(), (file) => `${routesDirectory()}/${file}${server && file.endsWith(".brm") ? SERVER_QUERY : ""}`, rpc, options.origins, isServe, middlewareFile(), buildId, hints.all, hints.bundles);
|
|
2429
2456
|
const serial = serialImports().join("\n");
|
|
2430
2457
|
const parts = [];
|
|
2458
|
+
const bundles = isServe ? "" : `import ${JSON.stringify(CLIENT_BUNDLES)};`;
|
|
2431
2459
|
for (const part of [
|
|
2432
2460
|
env ? `import ${JSON.stringify(env)};` : "",
|
|
2433
2461
|
serial,
|
|
2462
|
+
bundles,
|
|
2434
2463
|
code
|
|
2435
2464
|
]) if (part) parts.push(part);
|
|
2436
2465
|
return parts.join("\n");
|
|
@@ -2958,6 +2987,16 @@ function brumate(options = {}) {
|
|
|
2958
2987
|
add(loaderChunk);
|
|
2959
2988
|
add(coreChunk);
|
|
2960
2989
|
const bundleHints = {};
|
|
2990
|
+
const chunkUrls = {};
|
|
2991
|
+
const styleUrls = {};
|
|
2992
|
+
const members = {};
|
|
2993
|
+
let loadChunk = loaderChunk;
|
|
2994
|
+
for (const chunk of chunks.values()) for (const id of chunk.moduleIds) if (/[\\/]runtime[\\/]bundles\.[jt]s$/.test(id)) loadChunk = chunk.fileName;
|
|
2995
|
+
function loadUrl(name) {
|
|
2996
|
+
if (!relativeUrls || loadChunk === void 0) return `${base}${name}`;
|
|
2997
|
+
const relative = path.posix.relative(path.posix.dirname(loadChunk), name);
|
|
2998
|
+
return relative.startsWith(".") ? relative : `./${relative}`;
|
|
2999
|
+
}
|
|
2961
3000
|
for (const chunk of chunks.values()) {
|
|
2962
3001
|
const facade = chunk.facadeModuleId ?? "";
|
|
2963
3002
|
if (!facade.startsWith(`\0${BUNDLE}`)) continue;
|
|
@@ -2971,16 +3010,35 @@ function brumate(options = {}) {
|
|
|
2971
3010
|
}
|
|
2972
3011
|
walk(chunk.fileName);
|
|
2973
3012
|
const urls = [];
|
|
2974
|
-
|
|
2975
|
-
|
|
3013
|
+
const styles = /* @__PURE__ */ new Set();
|
|
3014
|
+
for (const name of files) {
|
|
3015
|
+
urls.push(`${base}${name}`);
|
|
3016
|
+
for (const css of chunks.get(name)?.viteMetadata?.importedCss ?? []) styles.add(css);
|
|
3017
|
+
}
|
|
3018
|
+
const id = facade.slice(24);
|
|
3019
|
+
const styleNames = [...styles];
|
|
3020
|
+
bundleHints[id] = urls;
|
|
3021
|
+
for (const name of styleNames) bundleHints[id].push(`${base}${name}`);
|
|
3022
|
+
chunkUrls[id] = loadUrl(chunk.fileName);
|
|
3023
|
+
styleUrls[id] = [];
|
|
3024
|
+
for (const name of styleNames) styleUrls[id].push(loadUrl(name));
|
|
3025
|
+
members[id] = bundleMembers.get(id) ?? [];
|
|
2976
3026
|
}
|
|
3027
|
+
let hasManifest = false;
|
|
3028
|
+
for (const chunk of chunks.values()) hasManifest ||= chunk.moduleIds.includes(`\0${MANIFEST}`);
|
|
3029
|
+
for (const root of hasManifest ? bundleMembers.keys() : []) if (chunkUrls[root] === void 0) this.error(`The client build has no chunk for the bundle of ${root}`);
|
|
2977
3030
|
await mkdir(path.join(outDir, ".brumate"), { recursive: true });
|
|
2978
3031
|
const all = [];
|
|
2979
3032
|
for (const name of hints) all.push(`${base}${name}`);
|
|
2980
|
-
|
|
3033
|
+
const clientOutput = {
|
|
2981
3034
|
all,
|
|
2982
|
-
bundles: bundleHints
|
|
2983
|
-
|
|
3035
|
+
bundles: bundleHints,
|
|
3036
|
+
chunks: chunkUrls,
|
|
3037
|
+
styles: styleUrls,
|
|
3038
|
+
members
|
|
3039
|
+
};
|
|
3040
|
+
if (hasManifest) builtHints = clientOutput;
|
|
3041
|
+
await writeFile(path.join(outDir, HINTS_FILE), JSON.stringify(clientOutput));
|
|
2984
3042
|
if (buildId !== void 0) {
|
|
2985
3043
|
const written = [];
|
|
2986
3044
|
for (const item of Object.values(bundle)) written.push(item.fileName);
|
|
@@ -3006,6 +3064,7 @@ function brumate(options = {}) {
|
|
|
3006
3064
|
const client = clientBuildDirectory(root, options.prerender);
|
|
3007
3065
|
buildId = process.env.BRUMATE_BUILD || readBuildId(client);
|
|
3008
3066
|
if (buildId === void 0) this.warn(`No ${BUILD_FILE} in ${path.relative(root, client)}, so the server does not know its build ID. Build the client first, or set BRUMATE_BUILD, for skew protection`);
|
|
3067
|
+
if (!clientHints().chunks) this.warn(`No ${HINTS_FILE} in ${path.relative(root, client)}, so the pages of this server load no client code. Build the client first`);
|
|
3009
3068
|
} else buildId = process.env.BRUMATE_BUILD || `${Date.now().toString(36)}${hash(String(Math.random()))}`;
|
|
3010
3069
|
}
|
|
3011
3070
|
coreModule = isServe ? void 0 : (await this.resolve("brumate/client", path.join(root, "index.html")))?.id;
|
|
@@ -3016,7 +3075,7 @@ function brumate(options = {}) {
|
|
|
3016
3075
|
writeRouteTypes();
|
|
3017
3076
|
},
|
|
3018
3077
|
async resolveId(id, importer, resolveOptions) {
|
|
3019
|
-
if (id === START || id === MANIFEST || id === SERVER || id === ROUTES || id === TESTING || id.startsWith(BUNDLE)) return `\0${id}`;
|
|
3078
|
+
if (id === START || id === MANIFEST || id === SERVER || id === ROUTES || id === TESTING || id === BUNDLES || id === CLIENT_BUNDLES || id.startsWith(BUNDLE)) return `\0${id}`;
|
|
3020
3079
|
const env = resolveOptions?.ssr ? void 0 : envFile();
|
|
3021
3080
|
const from = importer?.split("?")[0];
|
|
3022
3081
|
if (env && importer && from && from !== env && isScriptFile(from) && !importer.startsWith("\0") && !importer.includes(SERVER_QUERY) && !importer.includes("/node_modules/")) {
|
|
@@ -3058,16 +3117,34 @@ function brumate(options = {}) {
|
|
|
3058
3117
|
}
|
|
3059
3118
|
if (id === `\0${START}`) return [
|
|
3060
3119
|
options.navigate === false ? "import { startWithoutNavigation as start } from 'brumate/static-loader';" : "import { start } from 'brumate/loader';",
|
|
3061
|
-
`import { load
|
|
3120
|
+
`import { load } from ${JSON.stringify(MANIFEST)};`,
|
|
3062
3121
|
...isServe ? ["import { hotLoad } from 'brumate/hot';"] : [],
|
|
3063
|
-
`start({ load${isServe ? ": hotLoad(import.meta.hot, load)" : "
|
|
3122
|
+
`start({ load${isServe ? ": hotLoad(import.meta.hot, load)" : ""}${serialFile() ? `, serial: () => import(${JSON.stringify(serialFile())})` : ""}, rpc: ${JSON.stringify(rpc)}, navigate: ${JSON.stringify(options.navigate ?? true)}${buildId === void 0 ? "" : `, build: ${JSON.stringify(buildId)}`} });`,
|
|
3064
3123
|
...isServe && options.devtools !== false ? [`import('brumate/devtools').then((m) => m.installDevtools(${JSON.stringify(INSPECT)}, ${JSON.stringify(rpc)}, ${JSON.stringify({
|
|
3065
3124
|
version: BRUMATE_VERSION,
|
|
3066
3125
|
vite: version
|
|
3067
3126
|
})}, import.meta.hot));`] : []
|
|
3068
3127
|
].join("\n");
|
|
3069
3128
|
if (id === `\0${MANIFEST}`) return await manifest();
|
|
3129
|
+
if (id === `\0${BUNDLES}`) {
|
|
3130
|
+
const lines = [];
|
|
3131
|
+
for (const root of bundleMembers.keys()) lines.push(` ${JSON.stringify(root)}: () => import(${JSON.stringify(`${BUNDLE}${root}`)}),`);
|
|
3132
|
+
return [
|
|
3133
|
+
"export default {",
|
|
3134
|
+
...lines,
|
|
3135
|
+
"};"
|
|
3136
|
+
].join("\n");
|
|
3137
|
+
}
|
|
3070
3138
|
if (id.startsWith(`\0${BUNDLE}`)) return await bundleModule(id.slice(24));
|
|
3139
|
+
if (id === `\0${CLIENT_BUNDLES}`) {
|
|
3140
|
+
const hints = clientHints();
|
|
3141
|
+
const bundles = hints.chunks && hints.members ? {
|
|
3142
|
+
chunks: hints.chunks,
|
|
3143
|
+
styles: hints.styles,
|
|
3144
|
+
members: hints.members
|
|
3145
|
+
} : void 0;
|
|
3146
|
+
return ["import { setClientBundles } from 'brumate/server';", `setClientBundles(${JSON.stringify(bundles)});`].join("\n");
|
|
3147
|
+
}
|
|
3071
3148
|
if (id === `\0${SERVER}`) return serverRegistry(!loadOptions?.ssr);
|
|
3072
3149
|
if (id === `\0${ROUTES}`) return routeTree(!loadOptions?.ssr);
|
|
3073
3150
|
if (id === `\0${TESTING}`) {
|
|
@@ -3138,6 +3215,7 @@ function brumate(options = {}) {
|
|
|
3138
3215
|
} else {
|
|
3139
3216
|
code = isClient ? result.client : result.server;
|
|
3140
3217
|
map = isClient ? result.maps.client : result.maps.server;
|
|
3218
|
+
if (!isClient && !isServe) code += `\nimport ${JSON.stringify(CLIENT_BUNDLES)};`;
|
|
3141
3219
|
}
|
|
3142
3220
|
const sources = [];
|
|
3143
3221
|
if (map) for (const [index, name] of map.sources.entries()) sources.push(index === 0 ? file : name);
|