Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions packages/start/src/config/fs-routes/router.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { init } from "es-module-lexer";
import { parse } from "es-module-lexer";
import { init, parse } from "es-module-lexer";
import esbuild from "esbuild";
import fg from "fast-glob";
import fs from "fs";
import micromatch from "micromatch";
import { posix } from "path";
import { pathToRegexp } from "path-to-regexp";

import { normalize } from "node:path";
import { normalizePath } from "vite";

export { pathToRegexp };

Expand Down Expand Up @@ -104,7 +103,7 @@ export class BaseFileSystemRouter extends EventTarget {
}

async addRoute(src: string) {
src = normalize(src);
src = normalizePath(src);
if (this.isRoute(src)) {
try {
const route = this.toRoute(src);
Expand All @@ -130,7 +129,7 @@ export class BaseFileSystemRouter extends EventTarget {
}

async updateRoute(src: string) {
src = normalize(src);
src = normalizePath(src);
if (this.isRoute(src)) {
try {
const route = this.toRoute(src);
Expand All @@ -146,7 +145,7 @@ export class BaseFileSystemRouter extends EventTarget {
}

removeRoute(src: string) {
src = normalize(src);
src = normalizePath(src);
if (this.isRoute(src)) {
const path = this.toPath(src);
if (path === undefined) {
Expand Down
22 changes: 12 additions & 10 deletions packages/start/src/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { TanStackServerFnPlugin } from "@tanstack/server-functions-plugin";
import { defu } from "defu";
import { globSync } from "node:fs";
import { extname, isAbsolute, join, normalize } from "node:path";
import { extname, isAbsolute, join } from "node:path";
import { fileURLToPath } from "node:url";
import { type PluginOption } from "vite";
import { normalizePath, type PluginOption } from "vite";
import solid, { type Options as SolidOptions } from "vite-plugin-solid";

import { DEFAULT_EXTENSIONS, VIRTUAL_MODULES, VITE_ENVIRONMENTS } from "./constants.ts";
Expand Down Expand Up @@ -126,8 +126,10 @@ export function solidStart(options?: SolidStartOptions): Array<PluginOption> {
define: {
"import.meta.env.MANIFEST": `globalThis.MANIFEST`,
"import.meta.env.START_SSR": JSON.stringify(start.ssr),
"import.meta.env.START_APP_ENTRY": `"${appEntryPath}"`,
"import.meta.env.START_CLIENT_ENTRY": `"${handlers.client}"`,
// Use JSON.stringify so backslashes on Windows are escaped and
// esbuild receives a valid JS string literal for the define value
"import.meta.env.START_APP_ENTRY": JSON.stringify(appEntryPath),
"import.meta.env.START_CLIENT_ENTRY": JSON.stringify(handlers.client),
"import.meta.env.START_DEV_OVERLAY": JSON.stringify(start.devOverlay),
},
builder: {
Expand Down Expand Up @@ -173,26 +175,26 @@ export function solidStart(options?: SolidStartOptions): Array<PluginOption> {
envConsumer: "client",
envName: VITE_ENVIRONMENTS.client,
getRuntimeCode: () =>
`import { createServerReference } from "${normalize(
fileURLToPath(new URL("../server/server-runtime", import.meta.url)),
`import { createServerReference } from "${normalizePath(
fileURLToPath(new URL("../server/server-runtime", import.meta.url))
)}"`,
replacer: opts => `createServerReference('${opts.functionId}')`,
},
{
envConsumer: "server",
envName: VITE_ENVIRONMENTS.server,
getRuntimeCode: () =>
`import { createServerReference } from '${normalize(
fileURLToPath(new URL("../server/server-fns-runtime", import.meta.url)),
`import { createServerReference } from '${normalizePath(
fileURLToPath(new URL("../server/server-fns-runtime", import.meta.url))
)}'`,
replacer: opts => `createServerReference(${opts.fn}, '${opts.functionId}')`,
},
],
provider: {
envName: VITE_ENVIRONMENTS.server,
getRuntimeCode: () =>
`import { createServerReference } from '${normalize(
fileURLToPath(new URL("../server/server-fns-runtime", import.meta.url)),
`import { createServerReference } from '${normalizePath(
fileURLToPath(new URL("../server/server-fns-runtime", import.meta.url))
)}'`,
replacer: opts => `createServerReference(${opts.fn}, '${opts.functionId}')`,
},
Expand Down
Loading