@teamscala/service-boot 0.23.538 → 0.23.539
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/package.json
CHANGED
|
@@ -11,24 +11,27 @@ export const MANIFEST_FILE = "asset-manifest.json";
|
|
|
11
11
|
export interface AssetManifest {
|
|
12
12
|
stylesPath?: string;
|
|
13
13
|
hydratePath?: string;
|
|
14
|
-
buildFailed?: boolean;
|
|
15
|
-
buildFailedReason?: string;
|
|
16
|
-
buildFailedAt?: string;
|
|
17
14
|
sourceMaps?: SourceMapUploadResult;
|
|
18
15
|
}
|
|
19
16
|
|
|
17
|
+
export interface FailedBuildManifest {
|
|
18
|
+
buildFailed: true;
|
|
19
|
+
buildFailedReason: string;
|
|
20
|
+
buildFailedAt: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type ManifestFile = AssetManifest | FailedBuildManifest;
|
|
24
|
+
|
|
20
25
|
export async function readManifest(outDir: string): Promise<AssetManifest | null> {
|
|
21
26
|
const path = join(outDir, MANIFEST_FILE);
|
|
22
27
|
if (!(await Bun.file(path).exists())) return null;
|
|
23
28
|
try {
|
|
24
|
-
const parsed = await Bun.file(path).json() as
|
|
29
|
+
const parsed = (await Bun.file(path).json()) as ManifestFile;
|
|
30
|
+
if ("buildFailed" in parsed) return null;
|
|
25
31
|
if (parsed.stylesPath && parsed.hydratePath) {
|
|
26
32
|
return {
|
|
27
33
|
stylesPath: parsed.stylesPath,
|
|
28
34
|
hydratePath: parsed.hydratePath,
|
|
29
|
-
buildFailed: parsed.buildFailed,
|
|
30
|
-
buildFailedReason: parsed.buildFailedReason,
|
|
31
|
-
buildFailedAt: parsed.buildFailedAt,
|
|
32
35
|
sourceMaps: parsed.sourceMaps,
|
|
33
36
|
};
|
|
34
37
|
}
|
|
@@ -40,7 +43,7 @@ export async function readManifest(outDir: string): Promise<AssetManifest | null
|
|
|
40
43
|
|
|
41
44
|
export async function writeManifest(
|
|
42
45
|
outDir: string,
|
|
43
|
-
manifest:
|
|
46
|
+
manifest: ManifestFile,
|
|
44
47
|
): Promise<void> {
|
|
45
48
|
await Bun.write(
|
|
46
49
|
join(outDir, MANIFEST_FILE),
|
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
|
|
6
6
|
import { createCache } from "@teamscala/cache/create-cache";
|
|
7
7
|
import { themeFontsLink } from "./theme-fonts-link.ts";
|
|
8
|
+
import { MANIFEST_FILE, readManifest } from "./build-client-assets/manifest.ts";
|
|
8
9
|
import { join } from "node:path";
|
|
9
10
|
|
|
10
|
-
interface
|
|
11
|
+
interface TemplateManifest {
|
|
11
12
|
stylesPath: string;
|
|
12
13
|
hydratePath: string;
|
|
13
14
|
}
|
|
@@ -41,7 +42,7 @@ const htmlCache = createCache<CachedHtml>("service-boot:html-template", {
|
|
|
41
42
|
});
|
|
42
43
|
|
|
43
44
|
function manifestPath(): string {
|
|
44
|
-
return join(process.cwd(), "dist", "client",
|
|
45
|
+
return join(process.cwd(), "dist", "client", MANIFEST_FILE);
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
async function manifestMtimeMs(): Promise<number> {
|
|
@@ -52,18 +53,10 @@ async function manifestMtimeMs(): Promise<number> {
|
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
|
|
55
|
-
async function loadManifest(): Promise<
|
|
56
|
-
const
|
|
57
|
-
if (!
|
|
58
|
-
|
|
59
|
-
const parsed = (await Bun.file(path).json()) as Partial<AssetManifest>;
|
|
60
|
-
if (parsed.stylesPath && parsed.hydratePath) {
|
|
61
|
-
return { stylesPath: parsed.stylesPath, hydratePath: parsed.hydratePath };
|
|
62
|
-
}
|
|
63
|
-
} catch {
|
|
64
|
-
return null;
|
|
65
|
-
}
|
|
66
|
-
return null;
|
|
56
|
+
async function loadManifest(): Promise<TemplateManifest | null> {
|
|
57
|
+
const manifest = await readManifest(join(process.cwd(), "dist", "client"));
|
|
58
|
+
if (!manifest?.stylesPath || !manifest.hydratePath) return null;
|
|
59
|
+
return { stylesPath: manifest.stylesPath, hydratePath: manifest.hydratePath };
|
|
67
60
|
}
|
|
68
61
|
|
|
69
62
|
function manifestCacheKey(): string {
|