|
1 | | -import { type PluginOption, type ViteDevServer } from "vite"; |
| 1 | +import fs from "node:fs"; |
| 2 | +import path from "node:path"; |
| 3 | +import { type PluginOption, type ViteDevServer, version as viteVersion } from "vite"; |
2 | 4 |
|
3 | 5 | import { findStylesInModuleGraph } from "../server/collect-styles.ts"; |
4 | 6 | import { VIRTUAL_MODULES } from "./constants.ts"; |
@@ -40,26 +42,15 @@ export function manifest(start: SolidStartOptions): PluginOption { |
40 | 42 | v => "isEntry" in v && v.isEntry, |
41 | 43 | ); |
42 | 44 | if (!entry) throw new Error("No client entry found"); |
43 | | - let viteStrVersion = (devServer?.config?.logger as any)?.config?.version; |
44 | | - if (!viteStrVersion) { |
45 | | - try { |
46 | | - viteStrVersion = await import("vite").then(m => m.version); |
47 | | - } catch (e) { |
48 | | - // ignore |
49 | | - } |
50 | | - } |
51 | | - |
52 | 45 | let rawManifest: string | undefined; |
53 | 46 |
|
54 | | - const viteMajor = parseInt(viteStrVersion!.split('.')[0], 10); |
| 47 | + const viteMajor = parseInt(viteVersion.split('.')[0]!, 10); |
55 | 48 |
|
56 | 49 | const manifestKey = Object.keys(globalThis.START_CLIENT_BUNDLE).find(k => k.endsWith("manifest.json")); |
57 | 50 | if (manifestKey && viteMajor < 8) { |
58 | 51 | const manifestAsset = globalThis.START_CLIENT_BUNDLE[manifestKey] as any; |
59 | 52 | rawManifest = manifestAsset.source as string; |
60 | 53 | } else { |
61 | | - const fs = await import("node:fs"); |
62 | | - const path = await import("node:path"); |
63 | 54 | try { |
64 | 55 | const appRoot = (start as any).appRoot || "./src"; |
65 | 56 | let outDir = ".solid-start/client"; |
@@ -89,11 +80,11 @@ export function manifest(start: SolidStartOptions): PluginOption { |
89 | 80 | if (this.environment.mode !== "dev") |
90 | 81 | throw new Error("@manifest queries are only allowed in dev"); |
91 | 82 |
|
92 | | - const [path, query] = id.split("?"); |
| 83 | + const [urlPath, query] = id.split("?"); |
93 | 84 | const target = id.split("/")[2]!; |
94 | 85 | const params = new URLSearchParams(query); |
95 | | - if (!path || !query) return; |
96 | | - if (path.endsWith("assets")) { |
| 86 | + if (!urlPath || !query) return; |
| 87 | + if (urlPath.endsWith("assets")) { |
97 | 88 | const id = params.get("id"); |
98 | 89 | if (!id) { |
99 | 90 | throw new Error("Missing id to get assets."); |
|
0 commit comments