Skip to content
Merged
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
8 changes: 4 additions & 4 deletions packages/react-start/src/plugin/vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ const defaultEntryDir = path.resolve(
'default-entry',
)
const defaultEntryPaths = {
client: path.resolve(defaultEntryDir, 'client'),
server: path.resolve(defaultEntryDir, 'server'),
start: path.resolve(defaultEntryDir, 'start'),
client: path.resolve(defaultEntryDir, 'client.tsx'),
server: path.resolve(defaultEntryDir, 'server.ts'),
start: path.resolve(defaultEntryDir, 'start.ts'),
}

const isInsideRouterMonoRepo =
Expand Down Expand Up @@ -65,7 +65,7 @@ export function tanstackStart(
? ['react-dom/client']
: ['react-dom/server']),
// `@tanstack/react-store` has a dependency on `use-sync-external-store`, which is CJS.
// It therefore needs to included so that it is converted to ESM.
// It therefore needs to be included so that it is converted to ESM.
'@tanstack/react-router > @tanstack/react-store',
],
}
Expand Down
6 changes: 3 additions & 3 deletions packages/solid-start/src/plugin/vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ const defaultEntryDir = path.resolve(
'default-entry',
)
const defaultEntryPaths = {
client: path.resolve(defaultEntryDir, 'client'),
server: path.resolve(defaultEntryDir, 'server'),
start: path.resolve(defaultEntryDir, 'start'),
client: path.resolve(defaultEntryDir, 'client.tsx'),
server: path.resolve(defaultEntryDir, 'server.ts'),
start: path.resolve(defaultEntryDir, 'start.ts'),
}

export function tanstackStart(
Expand Down
1 change: 1 addition & 0 deletions packages/start-plugin-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"exsolve": "^1.0.7",
"pathe": "^2.0.3",
"srvx": "^0.8.2",
"tinyglobby": "^0.2.15",
"ufo": "^1.5.4",
"vitefu": "^1.1.1",
"xmlbuilder2": "^3.1.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/start-plugin-core/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export type ViteEnvironmentNames =
// if a user has a custom server/client entry point file, resolve.alias will point to this
// otherwise it will be aliased to the default entry point in the respective framework plugin
export const ENTRY_POINTS = {
client: 'virtual:tanstack-start-client-entry',
server: 'virtual:tanstack-start-server-request-entry',
client: '__tanstack-start-client-entry__',
server: '__tanstack-start-server-entry__',
// the start entry point must always be provided by the user
start: '#tanstack-start-entry',
router: '#tanstack-router-entry',
Expand Down
53 changes: 27 additions & 26 deletions packages/start-plugin-core/src/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import path from 'node:path'
import { trimPathRight } from '@tanstack/router-core'
import { VIRTUAL_MODULES } from '@tanstack/start-server-core'
import { TanStackServerFnPluginEnv } from '@tanstack/server-functions-plugin'
import * as vite from 'vite'
import { crawlFrameworkPkgs } from 'vitefu'
import { join } from 'pathe'
import { escapePath } from 'tinyglobby'
import { startManifestPlugin } from './start-manifest-plugin/plugin'
import { startCompilerPlugin } from './start-compiler-plugin/plugin'
import { ENTRY_POINTS, VITE_ENVIRONMENT_NAMES } from './constants'
Expand Down Expand Up @@ -134,37 +134,25 @@ export function TanStackStartVitePluginCore(
required: false,
})

let clientAlias: string
if (clientEntryPath) {
clientAlias = vite.normalizePath(
path.join('/@fs', path.resolve(root, clientEntryPath)),
)
} else {
clientAlias = corePluginOpts.defaultEntryPaths.client
}

let serverAlias: string
if (serverEntryPath) {
serverAlias = vite.normalizePath(path.resolve(root, serverEntryPath))
} else {
serverAlias = corePluginOpts.defaultEntryPaths.server
}

let startAlias: string
if (startFilePath) {
startAlias = vite.normalizePath(path.resolve(root, startFilePath))
} else {
startAlias = corePluginOpts.defaultEntryPaths.start
}
const clientAlias = vite.normalizePath(
clientEntryPath ?? corePluginOpts.defaultEntryPaths.client,
)
const serverAlias = vite.normalizePath(
serverEntryPath ?? corePluginOpts.defaultEntryPaths.server,
)
const startAlias = vite.normalizePath(
startFilePath ?? corePluginOpts.defaultEntryPaths.start,
)
const routerAlias = vite.normalizePath(routerFilePath)

const entryAliasConfiguration: Record<
(typeof ENTRY_POINTS)[keyof typeof ENTRY_POINTS],
string
> = {
[ENTRY_POINTS.start]: startAlias,
[ENTRY_POINTS.router]: routerFilePath,
[ENTRY_POINTS.client]: clientAlias,
[ENTRY_POINTS.server]: serverAlias,
[ENTRY_POINTS.start]: startAlias,
[ENTRY_POINTS.router]: routerAlias,
}

const startPackageName =
Expand Down Expand Up @@ -206,10 +194,16 @@ export function TanStackStartVitePluginCore(
},
outDir: getClientOutputDirectory(viteConfig),
},
optimizeDeps: {
// Ensure user code can be crawled for dependencies
entries: [clientAlias, routerAlias].map((entry) =>
// Entries are treated as `tinyglobby` patterns so need to be escaped
escapePath(entry),
),
},
},
[VITE_ENVIRONMENT_NAMES.server]: {
consumer: 'server',

build: {
ssr: true,
rollupOptions: {
Expand All @@ -225,6 +219,13 @@ export function TanStackStartVitePluginCore(
viteConfig.environments?.[VITE_ENVIRONMENT_NAMES.server]
?.build?.copyPublicDir ?? false,
},
optimizeDeps: {
// Ensure user code can be crawled for dependencies
entries: [serverAlias, startAlias, routerAlias].map((entry) =>
// Entries are treated as `tinyglobby` patterns so need to be escaped
escapePath(entry),
),
},
},
},

Expand Down
15 changes: 9 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading