@akanjs/devkit 3.3.0-rc.24 → 3.3.0-rc.26
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/CHANGELOG.md +294 -0
- package/akanApp/akanApp.host.ts +11 -0
- package/akanConfig/akanBin.ts +4 -0
- package/akanConfig/akanConfig.test.ts +11 -0
- package/akanConfig/akanConfig.ts +39 -137
- package/akanConfig/akanWorkers.test.ts +39 -0
- package/akanConfig/akanWorkers.ts +32 -0
- package/akanConfig/desktopServerConfig.ts +96 -0
- package/akanConfig/dockerImage.ts +20 -0
- package/akanConfig/types.ts +1 -0
- package/app/appBin.test.ts +63 -0
- package/app/appBin.ts +50 -0
- package/app/applicationBuildReporter.test.ts +32 -0
- package/app/applicationBuildReporter.ts +4 -0
- package/app/applicationBuildRunner.test.ts +3 -0
- package/app/applicationBuildRunner.ts +40 -4
- package/app/dictionarySizes.ts +94 -0
- package/artifact/implicitRootLayout.test.ts +19 -0
- package/artifact/implicitRootLayout.ts +16 -2
- package/artifact/storeBootstrap.test.ts +28 -0
- package/artifact/storeBootstrap.ts +60 -8
- package/biome.base.json +5 -1
- package/codeAgent/skills/akan-agent/SKILL.md +2 -2
- package/codeAgent/skills/akan-deps/SKILL.md +3 -2
- package/codeAgent/skills/akan-err/SKILL.md +2 -6
- package/codeAgent/skills/akan-mcp/SKILL.md +1 -1
- package/codeAgent/skills/akan-module/SKILL.md +2 -2
- package/codeAgent/skills/akan-query/SKILL.md +13 -20
- package/codeAgent/skills/akan-service/SKILL.md +2 -5
- package/codeAgent/skills/akan-transport/SKILL.md +5 -14
- package/codeAgent/skills/akan-ui/SKILL.md +2 -5
- package/context/akanContext.ts +2 -0
- package/executors/clientRuntimeKeyOrder.fixture.json +682 -0
- package/executors/clientRuntimeKeys.fixture.json +393 -0
- package/executors/clientRuntimeKeys.test.ts +1591 -0
- package/executors/executors.test.ts +2 -0
- package/executors/sysExecutor.ts +66 -3
- package/frontendBuild/allRoutesBuilder.ts +72 -3
- package/frontendBuild/autoImportSync.ts +3 -2
- package/frontendBuild/buildRouteClient.test.ts +513 -5
- package/frontendBuild/clientBuildTypes.ts +15 -0
- package/frontendBuild/clientEntriesBundler.ts +38 -0
- package/frontendBuild/clientEntryDiscovery.test.ts +60 -1
- package/frontendBuild/clientEntryDiscovery.ts +72 -4
- package/frontendBuild/csrDevModuleCompiler.test.ts +86 -0
- package/frontendBuild/csrDevModuleCompiler.ts +44 -8
- package/frontendBuild/csrDevPatcher.ts +33 -7
- package/frontendBuild/csrDevTypes.ts +9 -0
- package/frontendBuild/devBarrelImports.test.ts +70 -0
- package/frontendBuild/devBarrelImports.ts +80 -21
- package/frontendBuild/devRegistryBundler.ts +4 -2
- package/frontendBuild/devRouteRuntime.test.ts +492 -0
- package/frontendBuild/devRouteRuntime.ts +167 -0
- package/frontendBuild/dictionaryAssetBuilder.test.ts +316 -0
- package/frontendBuild/dictionaryAssetBuilder.ts +152 -16
- package/frontendBuild/dictionaryConstants.ts +82 -0
- package/frontendBuild/dictionaryPacking.test.ts +84 -0
- package/frontendBuild/dictionaryPacking.ts +92 -0
- package/frontendBuild/dictionaryRoutes.test.ts +186 -0
- package/frontendBuild/dictionaryRoutes.ts +225 -0
- package/frontendBuild/pagesBundleBuilder.test.ts +84 -0
- package/frontendBuild/pagesBundleBuilder.ts +78 -2
- package/frontendBuild/precompressArtifacts.ts +7 -0
- package/frontendBuild/registryMetadataFingerprint.ts +3 -3
- package/frontendBuild/routeClientBuilder.ts +288 -15
- package/frontendBuild/routeHandoffs.test.ts +119 -0
- package/frontendBuild/routeHandoffs.ts +94 -0
- package/frontendBuild/routeRuntimeCheck.test.ts +257 -0
- package/frontendBuild/routeRuntimeCheck.ts +241 -0
- package/frontendBuild/routeRuntimePays.test.ts +137 -0
- package/frontendBuild/routeRuntimePays.ts +117 -0
- package/frontendBuild/ssrBaseArtifactBuilder.ts +24 -34
- package/frontendBuild/ssrDevBundler.test.ts +150 -1
- package/frontendBuild/ssrDevBundler.ts +66 -11
- package/frontendBuild/vendorFileImports.test.ts +254 -0
- package/frontendBuild/vendorFileImports.ts +163 -0
- package/frontendBuild/vendorNarrowing.ts +28 -0
- package/frontendBuild/vendorSpecifiers.ts +2 -0
- package/incrementalBuilder/incrementalBuilder.proc.test.ts +79 -0
- package/incrementalBuilder/incrementalBuilder.proc.ts +20 -1
- package/mobile/desktopBin.ts +2 -2
- package/mobile/desktopServerStage.ts +1 -0
- package/package.json +4 -3
- package/quality/dictionaryKeys.test.ts +173 -0
- package/quality/dictionaryKeys.ts +415 -0
- package/quality/objectImportReport.test.ts +36 -0
- package/quality/objectImportReport.ts +102 -0
- package/quality/qualityScanner.ts +1 -1
- package/quality/routeRuntimeReport.test.ts +91 -0
- package/quality/routeRuntimeReport.ts +121 -0
- package/quality/runtimeConstantFacts.ts +71 -0
- package/quality/runtimeConstantGraph.ts +123 -0
- package/quality/runtimeConstantReads.ts +116 -0
- package/quality/runtimeImports.test.ts +190 -0
- package/quality/runtimeImports.ts +233 -0
- package/quality/runtimeKeyNames.ts +46 -0
- package/quality/runtimeLexicalScope.ts +132 -0
- package/quality/runtimeMarkerReach.test.ts +84 -0
- package/quality/runtimeMarkerReach.ts +255 -0
- package/quality/runtimeModuleFacts.ts +290 -0
- package/quality/runtimeNameTable.test.ts +172 -0
- package/quality/runtimeNameTable.ts +477 -0
- package/quality/runtimeScopeReport.test.ts +123 -0
- package/quality/runtimeScopeReport.ts +167 -0
- package/quality/runtimeSliceKey.ts +269 -0
- package/quality/runtimeSyntax.ts +133 -0
- package/quality/runtimeTable.fixture.ts +189 -0
- package/quality/runtimeUse.test.ts +737 -0
- package/quality/runtimeUse.ts +696 -0
- package/quality/runtimeUseReadable.test.ts +393 -0
- package/quality/ssrScanner.test.ts +13 -0
- package/quality/ssrScanner.ts +1 -1
- package/test/testHelpers.ts +11 -0
- package/transforms/barrelAnalyzer.ts +17 -1
- package/transforms/barrelImportsPlugin.ts +81 -13
- package/transforms/frameworkObjects.fixture.tsx +58 -0
- package/transforms/frameworkObjects.test.ts +54 -0
- package/transforms/modelReference.test.ts +196 -0
- package/transforms/modelReference.ts +39 -0
- package/transforms/objectImportEdits.ts +150 -0
- package/transforms/objectMemberImports.test.ts +347 -0
- package/transforms/objectMemberImports.ts +537 -0
- package/transforms/objectModule.test.ts +237 -0
- package/transforms/objectModule.ts +458 -0
- package/transforms/objectModuleAnalyzer.ts +104 -0
- package/transforms/reactIconImports.test.ts +231 -0
- package/transforms/reactIconImports.ts +325 -0
- package/transforms/routeConstants.ts +122 -0
- package/transforms/routeRuntime.test.ts +835 -0
- package/transforms/routeRuntime.ts +703 -0
- package/transforms/routeRuntimeEdits.ts +92 -0
- package/transforms/routeRuntimeGraph.ts +66 -0
- package/transforms/routeRuntimePlan.ts +244 -0
- package/transforms/signalDescriptors.test.ts +280 -0
- package/transforms/signalDescriptors.ts +227 -0
- package/transforms/thisFreeExports.ts +87 -0
- package/transforms/transforms.test.ts +139 -0
- package/workflow/executor.ts +6 -2
- package/workflow/index.ts +1 -0
- package/workflow/plan.ts +36 -7
- package/workflow/types.ts +1 -1
- package/workflow/uiTarget.ts +50 -0
- package/workspace/scanInfo.ts +1 -1
- package/workspace/workspaceLayout.ts +1 -0
|
@@ -4,6 +4,7 @@ import { lstat, mkdir, readFile, readlink, rm, stat, utimes, writeFile } from "n
|
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { AkanAppConfig } from "../akanConfig";
|
|
6
6
|
import { DevGeneratedIndexSync } from "../frontendBuild/devGeneratedIndexSync";
|
|
7
|
+
import { RouteRuntimeReport } from "../quality/routeRuntimeReport";
|
|
7
8
|
import {
|
|
8
9
|
createTempApp,
|
|
9
10
|
createTempLib,
|
|
@@ -629,6 +630,7 @@ describe("Workspace and app executor environment contracts", () => {
|
|
|
629
630
|
"cache/cssCandidates.json",
|
|
630
631
|
"cache/fontCache.json",
|
|
631
632
|
"cache/fonts/Assistant-400-normal-abc.woff2",
|
|
633
|
+
path.relative(".akan", RouteRuntimeReport.file),
|
|
632
634
|
];
|
|
633
635
|
const removed = [
|
|
634
636
|
"artifact/client/app.js",
|
package/executors/sysExecutor.ts
CHANGED
|
@@ -90,11 +90,74 @@ export class SysExecutor extends Executor {
|
|
|
90
90
|
);
|
|
91
91
|
return written;
|
|
92
92
|
}
|
|
93
|
-
#
|
|
93
|
+
async #syncClientPieces(scanInfo: AppInfo | LibInfo, synced: SysExecutor): Promise<FileContent[]> {
|
|
94
|
+
const pieceDir = "lib/__client";
|
|
95
|
+
const modulesOf = (info: AppInfo | LibInfo): string[] => [
|
|
96
|
+
...[...info.getLibInfos().values()].flatMap(modulesOf),
|
|
97
|
+
...info.getDatabaseModules(),
|
|
98
|
+
...info.getServiceModules(),
|
|
99
|
+
];
|
|
100
|
+
const scope = `${this.type}s/${this.name}`;
|
|
101
|
+
const scopesOf = (info: AppInfo | LibInfo, own: string): string[] => [
|
|
102
|
+
...[...info.getLibInfos().values()].flatMap((libInfo) => scopesOf(libInfo, `libs/${libInfo.name}`)),
|
|
103
|
+
own,
|
|
104
|
+
];
|
|
105
|
+
const { RuntimeNameTable } = await import("../quality/runtimeNameTable");
|
|
106
|
+
const { RuntimeConstantGraph } = await import("../quality/runtimeConstantGraph");
|
|
107
|
+
const table = await RuntimeNameTable.readScopes(this.workspace.workspaceRoot, [
|
|
108
|
+
...new Set(scopesOf(scanInfo, scope)),
|
|
109
|
+
]).catch((error: unknown) => {
|
|
110
|
+
if (synced.type === "app")
|
|
111
|
+
this.logger.warn(
|
|
112
|
+
`[client-runtime] The modules of ${scope} could not be read (${error instanceof Error ? error.message : String(error)}), so no store file under ${scope}/${pieceDir} loads the upload module's descriptors first, and a page naming only that store has no upload action. Run \`akan sync ${this.name}\` again once that is fixed.`,
|
|
113
|
+
);
|
|
114
|
+
return null;
|
|
115
|
+
});
|
|
116
|
+
const constants = table ? RuntimeConstantGraph.ofDisk(this.workspace.workspaceRoot, table) : null;
|
|
117
|
+
const written = (
|
|
118
|
+
await Promise.all([
|
|
119
|
+
this._applyTemplate({ basePath: pieceDir, template: "clientPiece/scope", scanInfo }),
|
|
120
|
+
...[...new Set(modulesOf(scanInfo))].map((model) =>
|
|
121
|
+
this._applyTemplate({
|
|
122
|
+
basePath: pieceDir,
|
|
123
|
+
template: "clientPiece/module",
|
|
124
|
+
scanInfo,
|
|
125
|
+
dict: {
|
|
126
|
+
model,
|
|
127
|
+
Model: capitalize(model),
|
|
128
|
+
descriptorsFirst: (table?.dependenciesOf(scope, model) ?? []).map(({ module }) => module).join(","),
|
|
129
|
+
},
|
|
130
|
+
options: {
|
|
131
|
+
constants: constants?.fetchNeedsOf(model) ?? undefined,
|
|
132
|
+
registration: constants?.modelOf(model) ?? undefined,
|
|
133
|
+
},
|
|
134
|
+
}),
|
|
135
|
+
),
|
|
136
|
+
...(constants
|
|
137
|
+
? [...scanInfo.getDatabaseModules(), ...scanInfo.getScalarModules()].map((model) =>
|
|
138
|
+
this._applyTemplate({
|
|
139
|
+
basePath: pieceDir,
|
|
140
|
+
template: "clientPiece/constant",
|
|
141
|
+
scanInfo,
|
|
142
|
+
dict: { model, Model: capitalize(model) },
|
|
143
|
+
options: constants.piecesBefore({ scope, module: model }),
|
|
144
|
+
}),
|
|
145
|
+
)
|
|
146
|
+
: []),
|
|
147
|
+
])
|
|
148
|
+
).flat();
|
|
149
|
+
const kept = new Set(written.map(({ filePath }) => path.basename(filePath)));
|
|
150
|
+
const stale = (await this.readdir(pieceDir)).filter((file) => !kept.has(file));
|
|
151
|
+
await Promise.all(stale.map((file) => this.remove(`${pieceDir}/${file}`)));
|
|
152
|
+
return written;
|
|
153
|
+
}
|
|
154
|
+
//? `synced` is the app or lib whose sync this is: a lib's files are written by the sync of each app mounting it.
|
|
155
|
+
#getScanTemplateTasks(scanInfo: AppInfo | LibInfo, synced: SysExecutor): (Promise<FileContent[]> | null)[] {
|
|
94
156
|
return [
|
|
95
157
|
this.#seedEnvFiles(),
|
|
96
158
|
this._applyTemplate({ basePath: "env", template: "env", scanInfo }),
|
|
97
159
|
this._applyTemplate({ basePath: "lib", template: "lib", scanInfo }),
|
|
160
|
+
this.#syncClientPieces(scanInfo, synced),
|
|
98
161
|
this._applyTemplate({ basePath: ".", template: "server.ts", scanInfo }),
|
|
99
162
|
this._applyTemplate({ basePath: ".", template: "client.ts", scanInfo }),
|
|
100
163
|
this.type === "lib" ? this._applyTemplate({ basePath: ".", template: "index.ts", scanInfo }) : null,
|
|
@@ -136,12 +199,12 @@ export class SysExecutor extends Executor {
|
|
|
136
199
|
//* Locked: `writeLib` rewrites dependency-lib barrels that other dev servers regenerate and watch too.
|
|
137
200
|
if (write)
|
|
138
201
|
await CodegenLock.run(this.workspace.workspaceRoot, `scan:${this.name}`, async () => {
|
|
139
|
-
await Promise.all(this.#getScanTemplateTasks(scanInfo));
|
|
202
|
+
await Promise.all(this.#getScanTemplateTasks(scanInfo, this));
|
|
140
203
|
await this.writeJson(`akan.${this.type}.json`, scanInfo.getScanResult());
|
|
141
204
|
await this.#updateDependencies(scanInfo);
|
|
142
205
|
if (writeLib) {
|
|
143
206
|
const libInfos = [...scanInfo.getLibInfos().values()];
|
|
144
|
-
await Promise.all(libInfos.flatMap((libInfo) => libInfo.exec.#getScanTemplateTasks(libInfo)));
|
|
207
|
+
await Promise.all(libInfos.flatMap((libInfo) => libInfo.exec.#getScanTemplateTasks(libInfo, this)));
|
|
145
208
|
}
|
|
146
209
|
await this.syncAgentsIndex(scanInfo);
|
|
147
210
|
});
|
|
@@ -7,10 +7,16 @@ import {
|
|
|
7
7
|
resolveSsrPageEntriesForApp,
|
|
8
8
|
} from "../artifact/implicitRootLayout";
|
|
9
9
|
import { computeRouteSeedIndex, type RouteSeedIndex } from "../artifact/routeSeedIndex";
|
|
10
|
+
import { StoreBootstrap } from "../artifact/storeBootstrap";
|
|
10
11
|
import type { App } from "../commandDecorators";
|
|
12
|
+
import { type RouteRuntimeDictionaryFallback, RouteRuntimeReport } from "../quality/routeRuntimeReport";
|
|
13
|
+
import { ModelReference } from "../transforms/modelReference";
|
|
14
|
+
import { RouteRuntime } from "../transforms/routeRuntime";
|
|
11
15
|
import type { ClientEntryDiscovery } from "./clientBuildTypes";
|
|
12
16
|
import { GraphClientEntryDiscovery } from "./clientEntryDiscovery";
|
|
17
|
+
import { DictionaryRoutes } from "./dictionaryRoutes";
|
|
13
18
|
import { type BuildRouteClientResult, RouteClientBuilder } from "./routeClientBuilder";
|
|
19
|
+
import { RouteHandoffs } from "./routeHandoffs";
|
|
14
20
|
import { RouteModulePreloads, type RuntimeChunks } from "./routeModulePreloads";
|
|
15
21
|
import { RoutesManifestArtifactSerializer } from "./routesManifestArtifactSerializer";
|
|
16
22
|
|
|
@@ -18,6 +24,8 @@ export interface BuildAllRoutesResult {
|
|
|
18
24
|
manifest: RoutesManifest;
|
|
19
25
|
manifestPath: string;
|
|
20
26
|
seedIndex: RouteSeedIndex;
|
|
27
|
+
/** A production build: the dictionary groups each route can show; a route left out loads every group. */
|
|
28
|
+
dictionaryRoutes?: Map<string, string[]>;
|
|
21
29
|
}
|
|
22
30
|
|
|
23
31
|
export class AllRoutesBuilder {
|
|
@@ -32,6 +40,8 @@ export class AllRoutesBuilder {
|
|
|
32
40
|
#knownSet = new Set<string>();
|
|
33
41
|
#routeIds: string[] = [];
|
|
34
42
|
#ssrEntriesByRoute = new Map<string, string[]>();
|
|
43
|
+
#entriesByRoute = new Map<string, string[]>();
|
|
44
|
+
#serverModulesByRoute = new Map<string, string[]>();
|
|
35
45
|
#externalsByChunkUrl: Record<string, string[]> = {};
|
|
36
46
|
#discovery: ClientEntryDiscovery | null = null;
|
|
37
47
|
|
|
@@ -49,6 +59,9 @@ export class AllRoutesBuilder {
|
|
|
49
59
|
const discovery = await GraphClientEntryDiscovery.create(this.#app);
|
|
50
60
|
this.#discovery = discovery;
|
|
51
61
|
const importsAs = await this.#ssrImportsAs(discovery, pageEntries);
|
|
62
|
+
const handoffs = await this.#readHandoffs();
|
|
63
|
+
const dictionary = this.#command === "build";
|
|
64
|
+
const unread = new Map<string, string[]>();
|
|
52
65
|
|
|
53
66
|
// Every route's entries go into one Bun.build: chunk splitting only dedupes within a single build.
|
|
54
67
|
const allEntries = new Set<string>();
|
|
@@ -56,13 +69,30 @@ export class AllRoutesBuilder {
|
|
|
56
69
|
const seeds = Array.from(new Set([...seedIndex.globalLayoutFiles, ...entry.seeds]));
|
|
57
70
|
const routeEntries = await discovery.discover(seeds);
|
|
58
71
|
for (const discovered of routeEntries) allEntries.add(discovered);
|
|
59
|
-
|
|
72
|
+
const ssrEntries = await discovery.discover(seeds, { importsAs });
|
|
73
|
+
const serverModules = handoffs || dictionary ? await discovery.serverModules(seeds, { importsAs }) : [];
|
|
74
|
+
if (dictionary) this.#serverModulesByRoute.set(entry.routeId, serverModules);
|
|
75
|
+
const handed = await handoffs?.read(serverModules);
|
|
76
|
+
const loaded = [...new Set([...ssrEntries, ...(handed?.referenceFiles ?? [])])].sort();
|
|
77
|
+
this.#ssrEntriesByRoute.set(entry.routeId, loaded);
|
|
78
|
+
const besidesReferences = handed ? routeEntries.filter((file) => !ModelReference.isFile(file)) : routeEntries;
|
|
79
|
+
this.#entriesByRoute.set(entry.routeId, [...new Set([...besidesReferences, ...loaded])]);
|
|
80
|
+
if (handed?.unread) {
|
|
81
|
+
const pinned = `${handed.unread.file} (${handed.unread.why})`;
|
|
82
|
+
unread.set(pinned, [...(unread.get(pinned) ?? []), entry.routeId]);
|
|
83
|
+
}
|
|
60
84
|
this.#routeIds.push(entry.routeId);
|
|
61
85
|
}
|
|
86
|
+
for (const [pinned, routeIds] of unread)
|
|
87
|
+
this.#app.logger.warn(
|
|
88
|
+
`[client-runtime] ${routeIds.length} route(s) count every model's runtime in the route table: what ${pinned} hands to client components cannot be read. Routes: ${routeIds.join(", ")}`,
|
|
89
|
+
);
|
|
62
90
|
this.#app.verbose(`[build-all] ${allEntries.size} client entries across ${this.#routeIds.length} routes`);
|
|
63
91
|
|
|
64
92
|
const delta = await this.#buildEntries([...allEntries]);
|
|
65
93
|
this.#mergeDelta(delta);
|
|
94
|
+
const dictionaryRoutes =
|
|
95
|
+
dictionary && delta.clientGraph ? await this.#readDictionaryRoutes(delta.clientGraph) : null;
|
|
66
96
|
this.#merged.knownEntries = Array.from(this.#knownSet);
|
|
67
97
|
this.#externalsByChunkUrl = delta.externalsByChunkUrl ?? {};
|
|
68
98
|
|
|
@@ -75,13 +105,41 @@ export class AllRoutesBuilder {
|
|
|
75
105
|
`[build-all] wrote ${manifestPath} routes=${this.#routeIds.length} entries=${this.#merged.knownEntries.length}`,
|
|
76
106
|
);
|
|
77
107
|
|
|
78
|
-
return { manifest, manifestPath, seedIndex };
|
|
108
|
+
return { manifest, manifestPath, seedIndex, ...(dictionaryRoutes ? { dictionaryRoutes } : {}) };
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async #readDictionaryRoutes(importsByModule: NonNullable<BuildRouteClientResult["clientGraph"]>) {
|
|
112
|
+
const { workspaceRoot } = this.#app.workspace;
|
|
113
|
+
const reader = await DictionaryRoutes.forApp(workspaceRoot, `apps/${this.#app.name}`, { importsByModule });
|
|
114
|
+
const groupsByRoute = new Map<string, string[]>();
|
|
115
|
+
const whole = new Map<string, RouteRuntimeDictionaryFallback>();
|
|
116
|
+
for (const routeId of this.#routeIds) {
|
|
117
|
+
const entries = this.#entriesByRoute.get(routeId) ?? [];
|
|
118
|
+
const read = reader.read({ entries, serverModules: this.#serverModulesByRoute.get(routeId) });
|
|
119
|
+
if (!read.whole) groupsByRoute.set(routeId, read.groups);
|
|
120
|
+
else {
|
|
121
|
+
const pinned = DictionaryRoutes.pinned(read.whole);
|
|
122
|
+
const known = whole.get(pinned) ?? { ...read.whole, routes: [] };
|
|
123
|
+
whole.set(pinned, { ...known, routes: [...known.routes, routeId] });
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
for (const [pinned, { routes, line: key }] of whole) {
|
|
127
|
+
const line = `[dictionary] ${routes.length} route(s) load the whole page dictionary: ${pinned}. Routes: ${routes.join(", ")}`;
|
|
128
|
+
if (key !== undefined) this.#app.logger.warn(line);
|
|
129
|
+
else this.#app.verbose(line);
|
|
130
|
+
}
|
|
131
|
+
await RouteRuntimeReport.addDictionary(this.#app.cwdPath, [...whole.values()]);
|
|
132
|
+
return groupsByRoute;
|
|
79
133
|
}
|
|
80
134
|
|
|
81
135
|
async #ssrImportsAs(discovery: GraphClientEntryDiscovery, pageEntries: PageEntry[]) {
|
|
82
136
|
const { specifier, ssrShell, importsNoSsrPageRenders } = ROOT_LAYOUT_SYSTEM;
|
|
83
137
|
const importsAs = new Map<string, ReadonlyMap<string, string | null>>();
|
|
84
|
-
|
|
138
|
+
//? The root layout registers every model's reference; a route loads only those its own server modules hand over.
|
|
139
|
+
const toShell = new Map<string, string | null>([
|
|
140
|
+
[specifier, ssrShell],
|
|
141
|
+
[ModelReference.registrySpecifier(this.#app.name), null],
|
|
142
|
+
]);
|
|
85
143
|
for (const { key, moduleAbsPath } of pageEntries)
|
|
86
144
|
if (isImplicitRootLayoutKey(key)) importsAs.set(path.resolve(moduleAbsPath), toShell);
|
|
87
145
|
const system = await discovery.resolveImport(specifier, this.#app.cwdPath);
|
|
@@ -89,6 +147,15 @@ export class AllRoutesBuilder {
|
|
|
89
147
|
return importsAs;
|
|
90
148
|
}
|
|
91
149
|
|
|
150
|
+
async #readHandoffs(): Promise<RouteHandoffs | null> {
|
|
151
|
+
if (this.#command !== "build" || (await StoreBootstrap.scopeOf(this.#app)) !== "page") return null;
|
|
152
|
+
const { workspaceRoot } = this.#app.workspace;
|
|
153
|
+
const scope = `apps/${this.#app.name}`;
|
|
154
|
+
const runtime = await RouteRuntime.read(workspaceRoot, scope).catch(() => null);
|
|
155
|
+
if (!runtime) return null;
|
|
156
|
+
return new RouteHandoffs(workspaceRoot, runtime, await ModelReference.filesOf(workspaceRoot, scope));
|
|
157
|
+
}
|
|
158
|
+
|
|
92
159
|
async writeModulePreloads(runtimeChunks: RuntimeChunks): Promise<RouteModulePreloads> {
|
|
93
160
|
const preloads = new RouteModulePreloads({
|
|
94
161
|
runtimeChunks,
|
|
@@ -133,6 +200,8 @@ export class AllRoutesBuilder {
|
|
|
133
200
|
knownEntries: this.#knownSet,
|
|
134
201
|
discovery: this.#discovery,
|
|
135
202
|
command: this.#command,
|
|
203
|
+
entriesByRoute: this.#entriesByRoute,
|
|
204
|
+
sizedEntriesByRoute: this.#ssrEntriesByRoute,
|
|
136
205
|
}).build();
|
|
137
206
|
this.#app.verbose(`[build-all] bundled ${delta.newEntries.length} entries (${Date.now() - started}ms)`);
|
|
138
207
|
return delta;
|
|
@@ -232,8 +232,9 @@ export class AutoImportSync {
|
|
|
232
232
|
const parts = rel.split(path.sep).filter(Boolean);
|
|
233
233
|
const [scope, project, facet] = parts;
|
|
234
234
|
if ((scope !== "apps" && scope !== "libs") || !project || !facet) return null;
|
|
235
|
-
//* `lib/__lib/`
|
|
236
|
-
|
|
235
|
+
//* `lib/__lib/` and `lib/__client/` are rewritten by every `akan sync`, so an edit there is discarded;
|
|
236
|
+
//* `lib/__scalar/` is real source.
|
|
237
|
+
if (facet === "lib" && (parts[3] === "__lib" || parts[3] === "__client")) return null;
|
|
237
238
|
const role = roleFor(facet, base);
|
|
238
239
|
if (!role) return null;
|
|
239
240
|
|