Skip to content

Commit f18a440

Browse files
committed
fix: resolve path on windows
1 parent 4a8d415 commit f18a440

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

packages/start/src/config/index.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { TanStackServerFnPlugin } from "@tanstack/server-functions-plugin";
22
import { defu } from "defu";
33
import { globSync } from "node:fs";
4-
import { extname, isAbsolute, join, normalize } from "node:path";
4+
import { extname, isAbsolute, join } from "node:path";
55
import { fileURLToPath } from "node:url";
6-
import { type PluginOption } from "vite";
6+
import { normalizePath, type PluginOption } from "vite";
77
import solid, { type Options as SolidOptions } from "vite-plugin-solid";
88

99
import { DEFAULT_EXTENSIONS, VIRTUAL_MODULES, VITE_ENVIRONMENTS } from "./constants.ts";
@@ -126,8 +126,10 @@ export function solidStart(options?: SolidStartOptions): Array<PluginOption> {
126126
define: {
127127
"import.meta.env.MANIFEST": `globalThis.MANIFEST`,
128128
"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),
131133
"import.meta.env.START_DEV_OVERLAY": JSON.stringify(start.devOverlay),
132134
},
133135
builder: {
@@ -173,26 +175,26 @@ export function solidStart(options?: SolidStartOptions): Array<PluginOption> {
173175
envConsumer: "client",
174176
envName: VITE_ENVIRONMENTS.client,
175177
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))
178180
)}"`,
179181
replacer: opts => `createServerReference('${opts.functionId}')`,
180182
},
181183
{
182184
envConsumer: "server",
183185
envName: VITE_ENVIRONMENTS.server,
184186
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))
187189
)}'`,
188190
replacer: opts => `createServerReference(${opts.fn}, '${opts.functionId}')`,
189191
},
190192
],
191193
provider: {
192194
envName: VITE_ENVIRONMENTS.server,
193195
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))
196198
)}'`,
197199
replacer: opts => `createServerReference(${opts.fn}, '${opts.functionId}')`,
198200
},

0 commit comments

Comments
 (0)