Skip to content

Commit 5338a03

Browse files
committed
fix: URL to path conversion in manifest resolver
1 parent 9d5d783 commit 5338a03

2 files changed

Lines changed: 37 additions & 20 deletions

File tree

.changeset/brown-mice-train.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@solidjs/start": patch
3+
---
4+
5+
Fix URL to path conversion in manifest resolver

packages/start/src/config/manifest.ts

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import fs from "node:fs";
22
import path from "node:path";
33
import { type PluginOption, type ViteDevServer, version as viteVersion } from "vite";
4+
import { fileURLToPath } from "node:url";
45

56
import { findStylesInModuleGraph } from "../server/collect-styles.ts";
67
import { VIRTUAL_MODULES } from "./constants.ts";
@@ -20,12 +21,16 @@ export function manifest(start: SolidStartOptions): PluginOption {
2021
return `\0${VIRTUAL_MODULES.clientViteManifest}`;
2122
if (id === VIRTUAL_MODULES.getClientManifest)
2223
return this.resolve(
23-
new URL("../server/manifest/client-manifest", import.meta.url).pathname,
24+
fileURLToPath(new URL("../server/manifest/client-manifest", import.meta.url)),
2425
);
2526
if (id === VIRTUAL_MODULES.getManifest) {
2627
return this.environment.config.consumer === "client"
27-
? this.resolve(new URL("../server/manifest/client-manifest", import.meta.url).pathname)
28-
: this.resolve(new URL("../server/manifest/ssr-manifest", import.meta.url).pathname);
28+
? this.resolve(
29+
fileURLToPath(new URL("../server/manifest/client-manifest", import.meta.url)),
30+
)
31+
: this.resolve(
32+
fileURLToPath(new URL("../server/manifest/ssr-manifest", import.meta.url)),
33+
);
2934
}
3035
if (id === VIRTUAL_MODULES.middleware) {
3136
if (start.middleware) return await this.resolve(start.middleware);
@@ -44,28 +49,35 @@ export function manifest(start: SolidStartOptions): PluginOption {
4449
if (!entry) throw new Error("No client entry found");
4550
let rawManifest: string | undefined;
4651

47-
const viteMajor = parseInt(viteVersion.split('.')[0]!, 10);
52+
const viteMajor = parseInt(viteVersion.split(".")[0]!, 10);
4853

49-
const manifestKey = Object.keys(globalThis.START_CLIENT_BUNDLE).find(k => k.endsWith("manifest.json"));
54+
const manifestKey = Object.keys(globalThis.START_CLIENT_BUNDLE).find(k =>
55+
k.endsWith("manifest.json"),
56+
);
5057
if (manifestKey && viteMajor < 8) {
5158
const manifestAsset = globalThis.START_CLIENT_BUNDLE[manifestKey] as any;
5259
rawManifest = manifestAsset.source as string;
5360
} else {
54-
try {
55-
const appRoot = (start as any).appRoot || "./src";
56-
let outDir = ".solid-start/client";
57-
if (devServer?.environments?.client?.config?.build?.outDir) {
58-
outDir = devServer.environments.client.config.build.outDir;
59-
} else if (this.environment?.config?.build?.outDir && this.environment?.config?.consumer === "client") {
60-
outDir = this.environment.config.build.outDir;
61-
} else if ((globalThis as any).START_CLIENT_OUT_DIR) {
62-
outDir = (globalThis as any).START_CLIENT_OUT_DIR;
63-
}
64-
const manifestPath = path.resolve(appRoot, "..", outDir, ".vite/manifest.json");
65-
rawManifest = fs.readFileSync(manifestPath, "utf-8");
66-
} catch (e) {
67-
throw new Error(`Manifest asset not found in bundle and could not be read from disk. Keys: ${Object.keys(globalThis.START_CLIENT_BUNDLE).join(", ")}. Error: ${e}`);
68-
}
61+
try {
62+
const appRoot = (start as any).appRoot || "./src";
63+
let outDir = ".solid-start/client";
64+
if (devServer?.environments?.client?.config?.build?.outDir) {
65+
outDir = devServer.environments.client.config.build.outDir;
66+
} else if (
67+
this.environment?.config?.build?.outDir &&
68+
this.environment?.config?.consumer === "client"
69+
) {
70+
outDir = this.environment.config.build.outDir;
71+
} else if ((globalThis as any).START_CLIENT_OUT_DIR) {
72+
outDir = (globalThis as any).START_CLIENT_OUT_DIR;
73+
}
74+
const manifestPath = path.resolve(appRoot, "..", outDir, ".vite/manifest.json");
75+
rawManifest = fs.readFileSync(manifestPath, "utf-8");
76+
} catch (e) {
77+
throw new Error(
78+
`Manifest asset not found in bundle and could not be read from disk. Keys: ${Object.keys(globalThis.START_CLIENT_BUNDLE).join(", ")}. Error: ${e}`,
79+
);
80+
}
6981
}
7082

7183
if (!rawManifest) {

0 commit comments

Comments
 (0)