Skip to content

Commit fed2f37

Browse files
committed
move imports to top
1 parent 4df5813 commit fed2f37

1 file changed

Lines changed: 7 additions & 16 deletions

File tree

packages/start/src/config/manifest.ts

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
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";
24

35
import { findStylesInModuleGraph } from "../server/collect-styles.ts";
46
import { VIRTUAL_MODULES } from "./constants.ts";
@@ -40,26 +42,15 @@ export function manifest(start: SolidStartOptions): PluginOption {
4042
v => "isEntry" in v && v.isEntry,
4143
);
4244
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-
5245
let rawManifest: string | undefined;
5346

54-
const viteMajor = parseInt(viteStrVersion!.split('.')[0], 10);
47+
const viteMajor = parseInt(viteVersion.split('.')[0]!, 10);
5548

5649
const manifestKey = Object.keys(globalThis.START_CLIENT_BUNDLE).find(k => k.endsWith("manifest.json"));
5750
if (manifestKey && viteMajor < 8) {
5851
const manifestAsset = globalThis.START_CLIENT_BUNDLE[manifestKey] as any;
5952
rawManifest = manifestAsset.source as string;
6053
} else {
61-
const fs = await import("node:fs");
62-
const path = await import("node:path");
6354
try {
6455
const appRoot = (start as any).appRoot || "./src";
6556
let outDir = ".solid-start/client";
@@ -89,11 +80,11 @@ export function manifest(start: SolidStartOptions): PluginOption {
8980
if (this.environment.mode !== "dev")
9081
throw new Error("@manifest queries are only allowed in dev");
9182

92-
const [path, query] = id.split("?");
83+
const [urlPath, query] = id.split("?");
9384
const target = id.split("/")[2]!;
9485
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")) {
9788
const id = params.get("id");
9889
if (!id) {
9990
throw new Error("Missing id to get assets.");

0 commit comments

Comments
 (0)