|
1 | 1 | import { TanStackServerFnPlugin } from "@tanstack/server-functions-plugin"; |
2 | 2 | import { defu } from "defu"; |
3 | 3 | import { globSync } from "node:fs"; |
4 | | -import { extname, isAbsolute, join, normalize } from "node:path"; |
| 4 | +import { extname, isAbsolute, join } from "node:path"; |
5 | 5 | import { fileURLToPath } from "node:url"; |
6 | | -import { type PluginOption } from "vite"; |
| 6 | +import { normalizePath, type PluginOption } from "vite"; |
7 | 7 | import solid, { type Options as SolidOptions } from "vite-plugin-solid"; |
8 | 8 |
|
9 | 9 | import { DEFAULT_EXTENSIONS, VIRTUAL_MODULES, VITE_ENVIRONMENTS } from "./constants.ts"; |
@@ -126,8 +126,10 @@ export function solidStart(options?: SolidStartOptions): Array<PluginOption> { |
126 | 126 | define: { |
127 | 127 | "import.meta.env.MANIFEST": `globalThis.MANIFEST`, |
128 | 128 | "import.meta.env.START_SSR": JSON.stringify(start.ssr), |
129 | | - "import.meta.env.START_APP_ENTRY": `"${appEntryPath}"`, |
130 | | - "import.meta.env.START_CLIENT_ENTRY": `"${handlers.client}"`, |
| 129 | + // Use JSON.stringify so backslashes on Windows are escaped and |
| 130 | + // esbuild receives a valid JS string literal for the define value |
| 131 | + "import.meta.env.START_APP_ENTRY": JSON.stringify(appEntryPath), |
| 132 | + "import.meta.env.START_CLIENT_ENTRY": JSON.stringify(handlers.client), |
131 | 133 | "import.meta.env.START_DEV_OVERLAY": JSON.stringify(start.devOverlay), |
132 | 134 | }, |
133 | 135 | builder: { |
@@ -173,26 +175,26 @@ export function solidStart(options?: SolidStartOptions): Array<PluginOption> { |
173 | 175 | envConsumer: "client", |
174 | 176 | envName: VITE_ENVIRONMENTS.client, |
175 | 177 | getRuntimeCode: () => |
176 | | - `import { createServerReference } from "${normalize( |
177 | | - fileURLToPath(new URL("../server/server-runtime", import.meta.url)), |
| 178 | + `import { createServerReference } from "${normalizePath( |
| 179 | + fileURLToPath(new URL("../server/server-runtime", import.meta.url)) |
178 | 180 | )}"`, |
179 | 181 | replacer: opts => `createServerReference('${opts.functionId}')`, |
180 | 182 | }, |
181 | 183 | { |
182 | 184 | envConsumer: "server", |
183 | 185 | envName: VITE_ENVIRONMENTS.server, |
184 | 186 | getRuntimeCode: () => |
185 | | - `import { createServerReference } from '${normalize( |
186 | | - fileURLToPath(new URL("../server/server-fns-runtime", import.meta.url)), |
| 187 | + `import { createServerReference } from '${normalizePath( |
| 188 | + fileURLToPath(new URL("../server/server-fns-runtime", import.meta.url)) |
187 | 189 | )}'`, |
188 | 190 | replacer: opts => `createServerReference(${opts.fn}, '${opts.functionId}')`, |
189 | 191 | }, |
190 | 192 | ], |
191 | 193 | provider: { |
192 | 194 | envName: VITE_ENVIRONMENTS.server, |
193 | 195 | getRuntimeCode: () => |
194 | | - `import { createServerReference } from '${normalize( |
195 | | - fileURLToPath(new URL("../server/server-fns-runtime", import.meta.url)), |
| 196 | + `import { createServerReference } from '${normalizePath( |
| 197 | + fileURLToPath(new URL("../server/server-fns-runtime", import.meta.url)) |
196 | 198 | )}'`, |
197 | 199 | replacer: opts => `createServerReference(${opts.fn}, '${opts.functionId}')`, |
198 | 200 | }, |
|
0 commit comments