Skip to content

Commit 748a4be

Browse files
fix: fix start vite plugin during dev and prod (#4736)
1 parent 86e0f8f commit 748a4be

File tree

6 files changed

+51
-28
lines changed

6 files changed

+51
-28
lines changed

package.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,6 @@
6868
"vite": "6.3.5",
6969
"vitest": "^3.0.6"
7070
},
71-
"resolutions": {
72-
"use-sync-external-store": "1.2.2"
73-
},
7471
"pnpm": {
7572
"overrides": {
7673
"react": "$react",
@@ -81,7 +78,6 @@
8178
"vite": "$vite",
8279
"@playwright/test": "$@playwright/test",
8380
"@tanstack/react-query": "5.66.0",
84-
"use-sync-external-store": "1.2.2",
8581
"@tanstack/history": "workspace:*",
8682
"@tanstack/router-core": "workspace:*",
8783
"@tanstack/react-router": "workspace:*",

packages/react-start-plugin/package.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,12 @@
4141
},
4242
"type": "module",
4343
"types": "dist/esm/index.d.ts",
44-
"main": "dist/cjs/index.cjs",
4544
"module": "dist/esm/index.js",
4645
"exports": {
4746
".": {
4847
"import": {
4948
"types": "./dist/esm/index.d.ts",
5049
"default": "./dist/esm/index.js"
51-
},
52-
"require": {
53-
"types": "./dist/cjs/index.d.cts",
54-
"default": "./dist/cjs/index.cjs"
5550
}
5651
},
5752
"./package.json": "./package.json"
@@ -66,6 +61,7 @@
6661
},
6762
"dependencies": {
6863
"@tanstack/start-plugin-core": "workspace:*",
64+
"pathe": "^2.0.3",
6965
"zod": "^3.24.2"
7066
},
7167
"devDependencies": {

packages/react-start-plugin/src/index.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import { fileURLToPath } from 'node:url'
12
import viteReact from '@vitejs/plugin-react'
23
import { TanStackStartVitePluginCore } from '@tanstack/start-plugin-core'
4+
import path from 'pathe'
35
import { getTanStackStartOptions } from './schema'
46
import type { TanStackStartInputConfig, WithReactPlugin } from './schema'
57
import type { PluginOption } from 'vite'
@@ -26,7 +28,39 @@ export function TanStackStartVitePlugin(
2628
)
2729
}
2830

31+
const isInsideRouterMonoRepo = (() => {
32+
const currentDir = path.dirname(fileURLToPath(import.meta.url))
33+
return path.basename(path.resolve(currentDir, '../../../')) === 'packages'
34+
})()
35+
2936
return [
37+
{
38+
name: 'tanstack-react-start:config',
39+
configEnvironment() {
40+
return {
41+
resolve: {
42+
dedupe: ['react', 'react-dom', '@tanstack/react-router'],
43+
44+
external: isInsideRouterMonoRepo
45+
? ['@tanstack/react-router', '@tanstack/react-router-devtools']
46+
: undefined,
47+
},
48+
49+
optimizeDeps: {
50+
exclude: ['@tanstack/react-router-devtools'],
51+
include: [
52+
'react',
53+
'react/jsx-runtime',
54+
'react/jsx-dev-runtime',
55+
'react-dom',
56+
'react-dom/client',
57+
'@tanstack/react-router',
58+
'@tanstack/react-store',
59+
],
60+
},
61+
}
62+
},
63+
},
3064
TanStackStartVitePluginCore(
3165
{
3266
framework: 'react',

packages/react-start-plugin/vite.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ export default mergeConfig(
1717
entry: './src/index.ts',
1818
srcDir: './src',
1919
outDir: './dist',
20+
cjs: false,
2021
}),
2122
)

packages/start-plugin-core/src/plugin.ts

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -126,23 +126,17 @@ export function TanStackStartVitePluginCore(
126126
},
127127
resolve: {
128128
noExternal: [
129-
'@tanstack/start-client',
130-
'@tanstack/start-client-core',
131-
'@tanstack/start-server',
132-
'@tanstack/start-server-core',
133-
'@tanstack/start-server-functions-fetcher',
134-
'@tanstack/start-server-functions-client',
135-
'@tanstack/start-server-functions-server',
136-
'@tanstack/start-router-manifest',
137-
'@tanstack/start-config',
138-
'@tanstack/server-functions-plugin',
139-
'nitropack',
140-
'@tanstack/**start**',
129+
'@tanstack/start**',
130+
`@tanstack/${opts.framework}-start**`,
141131
...Object.values(VIRTUAL_MODULES),
142132
],
133+
dedupe: [`@tanstack/${opts.framework}-start`],
143134
},
144135
optimizeDeps: {
145-
exclude: [...Object.values(VIRTUAL_MODULES)],
136+
exclude: [
137+
...Object.values(VIRTUAL_MODULES),
138+
`@tanstack/${opts.framework}-start`,
139+
],
146140
},
147141
/* prettier-ignore */
148142
define: {

pnpm-lock.yaml

Lines changed: 8 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)