@tanstack/react-start 1.167.20 → 1.167.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.rsc.d.ts +1 -0
- package/dist/esm/index.rsc.js +1 -0
- package/dist/esm/plugin/shared.d.ts +7 -0
- package/dist/esm/plugin/shared.js +15 -0
- package/dist/esm/plugin/shared.js.map +1 -0
- package/dist/esm/plugin/vite.d.ts +6 -2
- package/dist/esm/plugin/vite.js +58 -45
- package/dist/esm/plugin/vite.js.map +1 -1
- package/dist/esm/rsc/serialization/client.d.ts +1 -0
- package/dist/esm/rsc/serialization/client.js +2 -0
- package/dist/esm/rsc/serialization/server.d.ts +1 -0
- package/dist/esm/rsc/serialization/server.js +2 -0
- package/dist/esm/rsc.d.ts +1 -0
- package/dist/esm/rsc.js +1 -0
- package/dist/esm/rsc.rsc.d.ts +1 -0
- package/dist/esm/rsc.rsc.js +1 -0
- package/package.json +33 -1
- package/src/index.rsc.ts +1 -0
- package/src/plugin/shared.ts +22 -0
- package/src/plugin/vite.ts +90 -60
- package/src/rsc/serialization/client.ts +1 -0
- package/src/rsc/serialization/server.ts +1 -0
- package/src/rsc.rsc.ts +2 -0
- package/src/rsc.tsx +3 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@tanstack/start-client-core';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@tanstack/start-client-core";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import path from "pathe";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
//#region src/plugin/shared.ts
|
|
4
|
+
var currentDir = path.dirname(fileURLToPath(import.meta.url));
|
|
5
|
+
var reactStartPluginDir = currentDir;
|
|
6
|
+
var defaultEntryDir = path.resolve(currentDir, "..", "..", "plugin", "default-entry");
|
|
7
|
+
var reactStartDefaultEntryPaths = {
|
|
8
|
+
client: path.resolve(defaultEntryDir, "client.tsx"),
|
|
9
|
+
server: path.resolve(defaultEntryDir, "server.ts"),
|
|
10
|
+
start: path.resolve(defaultEntryDir, "start.ts")
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { reactStartDefaultEntryPaths, reactStartPluginDir };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","names":[],"sources":["../../../src/plugin/shared.ts"],"sourcesContent":["import { fileURLToPath } from 'node:url'\nimport path from 'pathe'\n\nconst currentDir = path.dirname(fileURLToPath(import.meta.url))\nexport const reactStartPluginDir = currentDir\nconst defaultEntryDir = path.resolve(\n currentDir,\n '..',\n '..',\n 'plugin',\n 'default-entry',\n)\n\nexport const reactStartDefaultEntryPaths = {\n client: path.resolve(defaultEntryDir, 'client.tsx'),\n server: path.resolve(defaultEntryDir, 'server.ts'),\n start: path.resolve(defaultEntryDir, 'start.ts'),\n}\n\nexport function resolvePackageEntryPath(packageName: string): string {\n return fileURLToPath(import.meta.resolve(packageName))\n}\n"],"mappings":";;;AAGA,IAAM,aAAa,KAAK,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC;AAC/D,IAAa,sBAAsB;AACnC,IAAM,kBAAkB,KAAK,QAC3B,YACA,MACA,MACA,UACA,gBACD;AAED,IAAa,8BAA8B;CACzC,QAAQ,KAAK,QAAQ,iBAAiB,aAAa;CACnD,QAAQ,KAAK,QAAQ,iBAAiB,YAAY;CAClD,OAAO,KAAK,QAAQ,iBAAiB,WAAW;CACjD"}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TanStackStartViteInputConfig } from '@tanstack/start-plugin-core';
|
|
2
2
|
import { PluginOption } from 'vite';
|
|
3
|
-
export declare function tanstackStart(options?:
|
|
3
|
+
export declare function tanstackStart(options?: TanStackStartViteInputConfig & {
|
|
4
|
+
rsc?: {
|
|
5
|
+
enabled?: boolean;
|
|
6
|
+
};
|
|
7
|
+
}): Array<PluginOption>;
|
package/dist/esm/plugin/vite.js
CHANGED
|
@@ -1,52 +1,65 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { reactStartDefaultEntryPaths, reactStartPluginDir } from "./shared.js";
|
|
2
|
+
import { START_ENVIRONMENT_NAMES, tanStackStartVite } from "@tanstack/start-plugin-core";
|
|
3
|
+
import { configureRsc, reactStartRscVitePlugin } from "@tanstack/react-start-rsc/plugin/vite";
|
|
3
4
|
import path from "pathe";
|
|
4
5
|
//#region src/plugin/vite.ts
|
|
5
|
-
var
|
|
6
|
-
var defaultEntryDir = path.resolve(currentDir, "..", "..", "plugin", "default-entry");
|
|
7
|
-
var defaultEntryPaths = {
|
|
8
|
-
client: path.resolve(defaultEntryDir, "client.tsx"),
|
|
9
|
-
server: path.resolve(defaultEntryDir, "server.ts"),
|
|
10
|
-
start: path.resolve(defaultEntryDir, "start.ts")
|
|
11
|
-
};
|
|
12
|
-
var isInsideRouterMonoRepo = path.basename(path.resolve(currentDir, "../../../../")) === "packages";
|
|
6
|
+
var isInsideRouterMonoRepo = path.basename(path.resolve(reactStartPluginDir, "../../../../")) === "packages";
|
|
13
7
|
function tanstackStart(options) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
configEnvironment(environmentName, options) {
|
|
17
|
-
return {
|
|
18
|
-
resolve: {
|
|
19
|
-
dedupe: [
|
|
20
|
-
"react",
|
|
21
|
-
"react-dom",
|
|
22
|
-
"@tanstack/react-start",
|
|
23
|
-
"@tanstack/react-router"
|
|
24
|
-
],
|
|
25
|
-
external: options.resolve?.noExternal === true || !isInsideRouterMonoRepo ? void 0 : ["@tanstack/react-router", "@tanstack/react-router-devtools"]
|
|
26
|
-
},
|
|
27
|
-
optimizeDeps: environmentName === VITE_ENVIRONMENT_NAMES.client || environmentName === VITE_ENVIRONMENT_NAMES.server && options.optimizeDeps?.noDiscovery === false ? {
|
|
28
|
-
exclude: [
|
|
29
|
-
"@tanstack/react-start",
|
|
30
|
-
"@tanstack/react-router",
|
|
31
|
-
"@tanstack/react-router-devtools",
|
|
32
|
-
"@tanstack/start-static-server-functions"
|
|
33
|
-
],
|
|
34
|
-
include: [
|
|
35
|
-
"react",
|
|
36
|
-
"react/jsx-runtime",
|
|
37
|
-
"react/jsx-dev-runtime",
|
|
38
|
-
"react-dom",
|
|
39
|
-
...environmentName === VITE_ENVIRONMENT_NAMES.client ? ["react-dom/client"] : ["react-dom/server"],
|
|
40
|
-
"@tanstack/react-router > @tanstack/react-store",
|
|
41
|
-
...options.optimizeDeps?.exclude?.find((x) => x === "@tanstack/react-form") ? ["@tanstack/react-form > @tanstack/react-store"] : []
|
|
42
|
-
]
|
|
43
|
-
} : void 0
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
}, TanStackStartVitePluginCore({
|
|
8
|
+
const rscConfig = options?.rsc?.enabled ?? false ? configureRsc() : void 0;
|
|
9
|
+
let corePluginOpts = {
|
|
47
10
|
framework: "react",
|
|
48
|
-
defaultEntryPaths
|
|
49
|
-
|
|
11
|
+
defaultEntryPaths: reactStartDefaultEntryPaths,
|
|
12
|
+
providerEnvironmentName: START_ENVIRONMENT_NAMES.server,
|
|
13
|
+
ssrIsProvider: true,
|
|
14
|
+
ssrResolverStrategy: { type: "default" }
|
|
15
|
+
};
|
|
16
|
+
const serverEnvironments = [START_ENVIRONMENT_NAMES.server, ...rscConfig ? [rscConfig.envName] : []];
|
|
17
|
+
if (rscConfig) corePluginOpts = {
|
|
18
|
+
...corePluginOpts,
|
|
19
|
+
providerEnvironmentName: rscConfig.providerEnvironmentName,
|
|
20
|
+
ssrIsProvider: false,
|
|
21
|
+
ssrResolverStrategy: rscConfig.ssrResolverStrategy,
|
|
22
|
+
serializationAdapters: rscConfig.serializationAdapters
|
|
23
|
+
};
|
|
24
|
+
return [
|
|
25
|
+
{
|
|
26
|
+
name: "tanstack-react-start:config",
|
|
27
|
+
configEnvironment(environmentName, options) {
|
|
28
|
+
const needsOptimizeDeps = environmentName === START_ENVIRONMENT_NAMES.client || serverEnvironments.includes(environmentName) && options.optimizeDeps?.noDiscovery === false;
|
|
29
|
+
const reactRouterInNoExternal = Array.isArray(options.resolve?.noExternal) && options.resolve.noExternal.some((pattern) => pattern === "@tanstack/react-router" || typeof pattern === "string" && pattern.includes("react-router"));
|
|
30
|
+
return {
|
|
31
|
+
resolve: {
|
|
32
|
+
dedupe: [
|
|
33
|
+
"react",
|
|
34
|
+
"react-dom",
|
|
35
|
+
"@tanstack/react-start",
|
|
36
|
+
"@tanstack/react-router"
|
|
37
|
+
],
|
|
38
|
+
external: options.resolve?.noExternal === true || !isInsideRouterMonoRepo || reactRouterInNoExternal ? void 0 : ["@tanstack/react-router", "@tanstack/react-router-devtools"]
|
|
39
|
+
},
|
|
40
|
+
optimizeDeps: needsOptimizeDeps ? {
|
|
41
|
+
exclude: [
|
|
42
|
+
"@tanstack/react-start",
|
|
43
|
+
"@tanstack/react-router",
|
|
44
|
+
"@tanstack/react-router-devtools",
|
|
45
|
+
"@tanstack/start-static-server-functions"
|
|
46
|
+
],
|
|
47
|
+
include: [
|
|
48
|
+
"react",
|
|
49
|
+
"react/jsx-runtime",
|
|
50
|
+
"react/jsx-dev-runtime",
|
|
51
|
+
"react-dom",
|
|
52
|
+
...environmentName === START_ENVIRONMENT_NAMES.client ? ["react-dom/client"] : ["react-dom/server"],
|
|
53
|
+
"@tanstack/react-router > @tanstack/react-store",
|
|
54
|
+
...options.optimizeDeps?.exclude?.find((x) => x === "@tanstack/react-form") ? ["@tanstack/react-form > @tanstack/react-store"] : []
|
|
55
|
+
]
|
|
56
|
+
} : void 0
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
rscConfig ? reactStartRscVitePlugin() : null,
|
|
61
|
+
tanStackStartVite(corePluginOpts, options)
|
|
62
|
+
];
|
|
50
63
|
}
|
|
51
64
|
//#endregion
|
|
52
65
|
export { tanstackStart };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.js","names":[],"sources":["../../../src/plugin/vite.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"vite.js","names":[],"sources":["../../../src/plugin/vite.ts"],"sourcesContent":["import {\n START_ENVIRONMENT_NAMES,\n tanStackStartVite,\n} from '@tanstack/start-plugin-core'\nimport {\n configureRsc,\n reactStartRscVitePlugin,\n} from '@tanstack/react-start-rsc/plugin/vite'\nimport path from 'pathe'\nimport { reactStartDefaultEntryPaths, reactStartPluginDir } from './shared'\nimport type { TanStackStartVitePluginCoreOptions } from '@tanstack/start-plugin-core/vite/types'\nimport type { TanStackStartViteInputConfig } from '@tanstack/start-plugin-core'\nimport type { PluginOption } from 'vite'\n\nconst isInsideRouterMonoRepo =\n path.basename(path.resolve(reactStartPluginDir, '../../../../')) ===\n 'packages'\n\nexport function tanstackStart(\n options?: TanStackStartViteInputConfig & { rsc?: { enabled?: boolean } },\n): Array<PluginOption> {\n const rscEnabled = options?.rsc?.enabled ?? false\n const rscConfig = rscEnabled ? configureRsc() : undefined\n let corePluginOpts: TanStackStartVitePluginCoreOptions = {\n framework: 'react',\n defaultEntryPaths: reactStartDefaultEntryPaths,\n providerEnvironmentName: START_ENVIRONMENT_NAMES.server,\n ssrIsProvider: true,\n ssrResolverStrategy: {\n type: 'default',\n },\n }\n\n const serverEnvironments: Array<string> = [\n START_ENVIRONMENT_NAMES.server,\n ...(rscConfig ? [rscConfig.envName] : []),\n ]\n\n if (rscConfig) {\n corePluginOpts = {\n ...corePluginOpts,\n providerEnvironmentName: rscConfig.providerEnvironmentName,\n ssrIsProvider: false,\n ssrResolverStrategy: rscConfig.ssrResolverStrategy,\n serializationAdapters: rscConfig.serializationAdapters,\n }\n }\n return [\n {\n name: 'tanstack-react-start:config',\n configEnvironment(environmentName, options) {\n const needsOptimizeDeps =\n environmentName === START_ENVIRONMENT_NAMES.client ||\n (serverEnvironments.includes(environmentName) &&\n // This indicates that the server environment has opted in to dependency optimization\n options.optimizeDeps?.noDiscovery === false)\n\n // Check if @tanstack/react-router is in noExternal (as array)\n const reactRouterInNoExternal =\n Array.isArray(options.resolve?.noExternal) &&\n options.resolve.noExternal.some(\n (pattern) =>\n pattern === '@tanstack/react-router' ||\n (typeof pattern === 'string' && pattern.includes('react-router')),\n )\n\n return {\n resolve: {\n dedupe: [\n 'react',\n 'react-dom',\n '@tanstack/react-start',\n '@tanstack/react-router',\n ],\n // Don't mark react-router as external if:\n // 1. noExternal is true (bundle everything)\n // 2. We're not in the router monorepo\n // 3. react-router is explicitly in noExternal for this environment\n external:\n options.resolve?.noExternal === true ||\n !isInsideRouterMonoRepo ||\n reactRouterInNoExternal\n ? undefined\n : ['@tanstack/react-router', '@tanstack/react-router-devtools'],\n },\n optimizeDeps: needsOptimizeDeps\n ? {\n // As `@tanstack/react-start` depends on `@tanstack/react-router`, we should exclude both.\n exclude: [\n '@tanstack/react-start',\n '@tanstack/react-router',\n '@tanstack/react-router-devtools',\n '@tanstack/start-static-server-functions',\n ],\n include: [\n 'react',\n 'react/jsx-runtime',\n 'react/jsx-dev-runtime',\n 'react-dom',\n ...(environmentName === START_ENVIRONMENT_NAMES.client\n ? ['react-dom/client']\n : ['react-dom/server']),\n // `@tanstack/react-store` has a dependency on `use-sync-external-store`, which is CJS.\n // It therefore needs to be included so that it is converted to ESM.\n '@tanstack/react-router > @tanstack/react-store',\n ...(options.optimizeDeps?.exclude?.find(\n (x) => x === '@tanstack/react-form',\n )\n ? ['@tanstack/react-form > @tanstack/react-store']\n : []),\n ],\n }\n : undefined,\n }\n },\n },\n rscConfig ? reactStartRscVitePlugin() : null,\n tanStackStartVite(corePluginOpts, options),\n ]\n}\n"],"mappings":";;;;;AAcA,IAAM,yBACJ,KAAK,SAAS,KAAK,QAAQ,qBAAqB,eAAe,CAAC,KAChE;AAEF,SAAgB,cACd,SACqB;CAErB,MAAM,YADa,SAAS,KAAK,WAAW,QACb,cAAc,GAAG,KAAA;CAChD,IAAI,iBAAqD;EACvD,WAAW;EACX,mBAAmB;EACnB,yBAAyB,wBAAwB;EACjD,eAAe;EACf,qBAAqB,EACnB,MAAM,WACP;EACF;CAED,MAAM,qBAAoC,CACxC,wBAAwB,QACxB,GAAI,YAAY,CAAC,UAAU,QAAQ,GAAG,EAAE,CACzC;AAED,KAAI,UACF,kBAAiB;EACf,GAAG;EACH,yBAAyB,UAAU;EACnC,eAAe;EACf,qBAAqB,UAAU;EAC/B,uBAAuB,UAAU;EAClC;AAEH,QAAO;EACL;GACE,MAAM;GACN,kBAAkB,iBAAiB,SAAS;IAC1C,MAAM,oBACJ,oBAAoB,wBAAwB,UAC3C,mBAAmB,SAAS,gBAAgB,IAE3C,QAAQ,cAAc,gBAAgB;IAG1C,MAAM,0BACJ,MAAM,QAAQ,QAAQ,SAAS,WAAW,IAC1C,QAAQ,QAAQ,WAAW,MACxB,YACC,YAAY,4BACX,OAAO,YAAY,YAAY,QAAQ,SAAS,eAAe,CACnE;AAEH,WAAO;KACL,SAAS;MACP,QAAQ;OACN;OACA;OACA;OACA;OACD;MAKD,UACE,QAAQ,SAAS,eAAe,QAChC,CAAC,0BACD,0BACI,KAAA,IACA,CAAC,0BAA0B,kCAAkC;MACpE;KACD,cAAc,oBACV;MAEE,SAAS;OACP;OACA;OACA;OACA;OACD;MACD,SAAS;OACP;OACA;OACA;OACA;OACA,GAAI,oBAAoB,wBAAwB,SAC5C,CAAC,mBAAmB,GACpB,CAAC,mBAAmB;OAGxB;OACA,GAAI,QAAQ,cAAc,SAAS,MAChC,MAAM,MAAM,uBACd,GACG,CAAC,+CAA+C,GAChD,EAAE;OACP;MACF,GACD,KAAA;KACL;;GAEJ;EACD,YAAY,yBAAyB,GAAG;EACxC,kBAAkB,gBAAgB,QAAQ;EAC3C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { rscSerializationAdapter } from '@tanstack/react-start-rsc/serialization.client';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { rscSerializationAdapter } from '@tanstack/react-start-rsc/serialization.server';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@tanstack/react-start-rsc';
|
package/dist/esm/rsc.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@tanstack/react-start-rsc";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@tanstack/react-start-rsc';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@tanstack/react-start-rsc";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/react-start",
|
|
3
|
-
"version": "1.167.
|
|
3
|
+
"version": "1.167.21",
|
|
4
4
|
"description": "Modern and scalable routing for React applications",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -27,6 +27,10 @@
|
|
|
27
27
|
"types": "dist/esm/index.d.ts",
|
|
28
28
|
"exports": {
|
|
29
29
|
".": {
|
|
30
|
+
"react-server": {
|
|
31
|
+
"types": "./dist/esm/index.rsc.d.ts",
|
|
32
|
+
"default": "./dist/esm/index.rsc.js"
|
|
33
|
+
},
|
|
30
34
|
"import": {
|
|
31
35
|
"types": "./dist/esm/index.d.ts",
|
|
32
36
|
"default": "./dist/esm/index.js"
|
|
@@ -74,6 +78,28 @@
|
|
|
74
78
|
"default": "./dist/default-entry/esm/server.js"
|
|
75
79
|
}
|
|
76
80
|
},
|
|
81
|
+
"./rsc": {
|
|
82
|
+
"react-server": {
|
|
83
|
+
"types": "./dist/esm/rsc.rsc.d.ts",
|
|
84
|
+
"default": "./dist/esm/rsc.rsc.js"
|
|
85
|
+
},
|
|
86
|
+
"import": {
|
|
87
|
+
"types": "./dist/esm/rsc.d.ts",
|
|
88
|
+
"default": "./dist/esm/rsc.js"
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
"./rsc/serialization/server": {
|
|
92
|
+
"import": {
|
|
93
|
+
"types": "./dist/esm/rsc/serialization/server.d.ts",
|
|
94
|
+
"default": "./dist/esm/rsc/serialization/server.js"
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
"./rsc/serialization/client": {
|
|
98
|
+
"import": {
|
|
99
|
+
"types": "./dist/esm/rsc/serialization/client.d.ts",
|
|
100
|
+
"default": "./dist/esm/rsc/serialization/client.js"
|
|
101
|
+
}
|
|
102
|
+
},
|
|
77
103
|
"./server-only": {
|
|
78
104
|
"import": {
|
|
79
105
|
"types": "./dist/esm/server-only.d.ts",
|
|
@@ -104,6 +130,7 @@
|
|
|
104
130
|
"@tanstack/react-start-client": "1.166.29",
|
|
105
131
|
"@tanstack/react-start-server": "1.166.29",
|
|
106
132
|
"@tanstack/router-utils": "^1.161.6",
|
|
133
|
+
"@tanstack/react-start-rsc": "0.0.1",
|
|
107
134
|
"@tanstack/start-plugin-core": "1.167.18",
|
|
108
135
|
"@tanstack/react-router": "1.168.13",
|
|
109
136
|
"@tanstack/start-client-core": "1.167.10",
|
|
@@ -114,6 +141,11 @@
|
|
|
114
141
|
"react-dom": ">=18.0.0 || >=19.0.0",
|
|
115
142
|
"vite": ">=7.0.0"
|
|
116
143
|
},
|
|
144
|
+
"peerDependenciesMeta": {
|
|
145
|
+
"@vitejs/plugin-rsc": {
|
|
146
|
+
"optional": true
|
|
147
|
+
}
|
|
148
|
+
},
|
|
117
149
|
"devDependencies": {
|
|
118
150
|
"@tanstack/intent": "^0.0.14",
|
|
119
151
|
"@types/node": ">=20"
|
package/src/index.rsc.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@tanstack/start-client-core'
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url'
|
|
2
|
+
import path from 'pathe'
|
|
3
|
+
|
|
4
|
+
const currentDir = path.dirname(fileURLToPath(import.meta.url))
|
|
5
|
+
export const reactStartPluginDir = currentDir
|
|
6
|
+
const defaultEntryDir = path.resolve(
|
|
7
|
+
currentDir,
|
|
8
|
+
'..',
|
|
9
|
+
'..',
|
|
10
|
+
'plugin',
|
|
11
|
+
'default-entry',
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
export const reactStartDefaultEntryPaths = {
|
|
15
|
+
client: path.resolve(defaultEntryDir, 'client.tsx'),
|
|
16
|
+
server: path.resolve(defaultEntryDir, 'server.ts'),
|
|
17
|
+
start: path.resolve(defaultEntryDir, 'start.ts'),
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function resolvePackageEntryPath(packageName: string): string {
|
|
21
|
+
return fileURLToPath(import.meta.resolve(packageName))
|
|
22
|
+
}
|
package/src/plugin/vite.ts
CHANGED
|
@@ -1,36 +1,69 @@
|
|
|
1
|
-
import { fileURLToPath } from 'node:url'
|
|
2
1
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
START_ENVIRONMENT_NAMES,
|
|
3
|
+
tanStackStartVite,
|
|
5
4
|
} from '@tanstack/start-plugin-core'
|
|
5
|
+
import {
|
|
6
|
+
configureRsc,
|
|
7
|
+
reactStartRscVitePlugin,
|
|
8
|
+
} from '@tanstack/react-start-rsc/plugin/vite'
|
|
6
9
|
import path from 'pathe'
|
|
7
|
-
import
|
|
10
|
+
import { reactStartDefaultEntryPaths, reactStartPluginDir } from './shared'
|
|
11
|
+
import type { TanStackStartVitePluginCoreOptions } from '@tanstack/start-plugin-core/vite/types'
|
|
12
|
+
import type { TanStackStartViteInputConfig } from '@tanstack/start-plugin-core'
|
|
8
13
|
import type { PluginOption } from 'vite'
|
|
9
14
|
|
|
10
|
-
const currentDir = path.dirname(fileURLToPath(import.meta.url))
|
|
11
|
-
const defaultEntryDir = path.resolve(
|
|
12
|
-
currentDir,
|
|
13
|
-
'..',
|
|
14
|
-
'..',
|
|
15
|
-
'plugin',
|
|
16
|
-
'default-entry',
|
|
17
|
-
)
|
|
18
|
-
const defaultEntryPaths = {
|
|
19
|
-
client: path.resolve(defaultEntryDir, 'client.tsx'),
|
|
20
|
-
server: path.resolve(defaultEntryDir, 'server.ts'),
|
|
21
|
-
start: path.resolve(defaultEntryDir, 'start.ts'),
|
|
22
|
-
}
|
|
23
|
-
|
|
24
15
|
const isInsideRouterMonoRepo =
|
|
25
|
-
path.basename(path.resolve(
|
|
16
|
+
path.basename(path.resolve(reactStartPluginDir, '../../../../')) ===
|
|
17
|
+
'packages'
|
|
26
18
|
|
|
27
19
|
export function tanstackStart(
|
|
28
|
-
options?:
|
|
20
|
+
options?: TanStackStartViteInputConfig & { rsc?: { enabled?: boolean } },
|
|
29
21
|
): Array<PluginOption> {
|
|
22
|
+
const rscEnabled = options?.rsc?.enabled ?? false
|
|
23
|
+
const rscConfig = rscEnabled ? configureRsc() : undefined
|
|
24
|
+
let corePluginOpts: TanStackStartVitePluginCoreOptions = {
|
|
25
|
+
framework: 'react',
|
|
26
|
+
defaultEntryPaths: reactStartDefaultEntryPaths,
|
|
27
|
+
providerEnvironmentName: START_ENVIRONMENT_NAMES.server,
|
|
28
|
+
ssrIsProvider: true,
|
|
29
|
+
ssrResolverStrategy: {
|
|
30
|
+
type: 'default',
|
|
31
|
+
},
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const serverEnvironments: Array<string> = [
|
|
35
|
+
START_ENVIRONMENT_NAMES.server,
|
|
36
|
+
...(rscConfig ? [rscConfig.envName] : []),
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
if (rscConfig) {
|
|
40
|
+
corePluginOpts = {
|
|
41
|
+
...corePluginOpts,
|
|
42
|
+
providerEnvironmentName: rscConfig.providerEnvironmentName,
|
|
43
|
+
ssrIsProvider: false,
|
|
44
|
+
ssrResolverStrategy: rscConfig.ssrResolverStrategy,
|
|
45
|
+
serializationAdapters: rscConfig.serializationAdapters,
|
|
46
|
+
}
|
|
47
|
+
}
|
|
30
48
|
return [
|
|
31
49
|
{
|
|
32
50
|
name: 'tanstack-react-start:config',
|
|
33
51
|
configEnvironment(environmentName, options) {
|
|
52
|
+
const needsOptimizeDeps =
|
|
53
|
+
environmentName === START_ENVIRONMENT_NAMES.client ||
|
|
54
|
+
(serverEnvironments.includes(environmentName) &&
|
|
55
|
+
// This indicates that the server environment has opted in to dependency optimization
|
|
56
|
+
options.optimizeDeps?.noDiscovery === false)
|
|
57
|
+
|
|
58
|
+
// Check if @tanstack/react-router is in noExternal (as array)
|
|
59
|
+
const reactRouterInNoExternal =
|
|
60
|
+
Array.isArray(options.resolve?.noExternal) &&
|
|
61
|
+
options.resolve.noExternal.some(
|
|
62
|
+
(pattern) =>
|
|
63
|
+
pattern === '@tanstack/react-router' ||
|
|
64
|
+
(typeof pattern === 'string' && pattern.includes('react-router')),
|
|
65
|
+
)
|
|
66
|
+
|
|
34
67
|
return {
|
|
35
68
|
resolve: {
|
|
36
69
|
dedupe: [
|
|
@@ -39,52 +72,49 @@ export function tanstackStart(
|
|
|
39
72
|
'@tanstack/react-start',
|
|
40
73
|
'@tanstack/react-router',
|
|
41
74
|
],
|
|
75
|
+
// Don't mark react-router as external if:
|
|
76
|
+
// 1. noExternal is true (bundle everything)
|
|
77
|
+
// 2. We're not in the router monorepo
|
|
78
|
+
// 3. react-router is explicitly in noExternal for this environment
|
|
42
79
|
external:
|
|
43
|
-
options.resolve?.noExternal === true ||
|
|
80
|
+
options.resolve?.noExternal === true ||
|
|
81
|
+
!isInsideRouterMonoRepo ||
|
|
82
|
+
reactRouterInNoExternal
|
|
44
83
|
? undefined
|
|
45
84
|
: ['@tanstack/react-router', '@tanstack/react-router-devtools'],
|
|
46
85
|
},
|
|
47
|
-
optimizeDeps:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
'react/
|
|
63
|
-
'react/
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
'@tanstack/react-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
: []),
|
|
76
|
-
],
|
|
77
|
-
}
|
|
78
|
-
: undefined,
|
|
86
|
+
optimizeDeps: needsOptimizeDeps
|
|
87
|
+
? {
|
|
88
|
+
// As `@tanstack/react-start` depends on `@tanstack/react-router`, we should exclude both.
|
|
89
|
+
exclude: [
|
|
90
|
+
'@tanstack/react-start',
|
|
91
|
+
'@tanstack/react-router',
|
|
92
|
+
'@tanstack/react-router-devtools',
|
|
93
|
+
'@tanstack/start-static-server-functions',
|
|
94
|
+
],
|
|
95
|
+
include: [
|
|
96
|
+
'react',
|
|
97
|
+
'react/jsx-runtime',
|
|
98
|
+
'react/jsx-dev-runtime',
|
|
99
|
+
'react-dom',
|
|
100
|
+
...(environmentName === START_ENVIRONMENT_NAMES.client
|
|
101
|
+
? ['react-dom/client']
|
|
102
|
+
: ['react-dom/server']),
|
|
103
|
+
// `@tanstack/react-store` has a dependency on `use-sync-external-store`, which is CJS.
|
|
104
|
+
// It therefore needs to be included so that it is converted to ESM.
|
|
105
|
+
'@tanstack/react-router > @tanstack/react-store',
|
|
106
|
+
...(options.optimizeDeps?.exclude?.find(
|
|
107
|
+
(x) => x === '@tanstack/react-form',
|
|
108
|
+
)
|
|
109
|
+
? ['@tanstack/react-form > @tanstack/react-store']
|
|
110
|
+
: []),
|
|
111
|
+
],
|
|
112
|
+
}
|
|
113
|
+
: undefined,
|
|
79
114
|
}
|
|
80
115
|
},
|
|
81
116
|
},
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
framework: 'react',
|
|
85
|
-
defaultEntryPaths,
|
|
86
|
-
},
|
|
87
|
-
options,
|
|
88
|
-
),
|
|
117
|
+
rscConfig ? reactStartRscVitePlugin() : null,
|
|
118
|
+
tanStackStartVite(corePluginOpts, options),
|
|
89
119
|
]
|
|
90
120
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { rscSerializationAdapter } from '@tanstack/react-start-rsc/serialization.client'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { rscSerializationAdapter } from '@tanstack/react-start-rsc/serialization.server'
|
package/src/rsc.rsc.ts
ADDED
package/src/rsc.tsx
ADDED