@lovable.dev/vite-tanstack-config 1.6.0 → 2.0.0-rc.0
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/index.cjs +29 -11
- package/dist/index.d.cts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +29 -11
- package/package.json +16 -17
package/dist/index.cjs
CHANGED
|
@@ -130,6 +130,7 @@ function applyWatchDebounceDefaults(config) {
|
|
|
130
130
|
}
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
|
+
var SSR_CAPTURE_KEY = "__LOVABLE_TANSTACK_CAPTURE_SSR_ERROR__";
|
|
133
134
|
function devSsrErrorLogger() {
|
|
134
135
|
let lastCapture;
|
|
135
136
|
const CAPTURE_TTL_MS = 5e3;
|
|
@@ -151,6 +152,7 @@ function devSsrErrorLogger() {
|
|
|
151
152
|
name: "dev-ssr-error-logger",
|
|
152
153
|
apply: "serve",
|
|
153
154
|
configureServer(server) {
|
|
155
|
+
globalThis[SSR_CAPTURE_KEY] = capture;
|
|
154
156
|
const g = globalThis;
|
|
155
157
|
if (typeof g.addEventListener === "function") {
|
|
156
158
|
const addListener = g.addEventListener;
|
|
@@ -188,6 +190,21 @@ function devSsrErrorLogger() {
|
|
|
188
190
|
};
|
|
189
191
|
next();
|
|
190
192
|
});
|
|
193
|
+
},
|
|
194
|
+
transform(code, id) {
|
|
195
|
+
const normalizedId = id.replace(/\\/g, "/");
|
|
196
|
+
const isTargetModule = normalizedId.includes("/@tanstack/start-server-core/src/request-response.ts") || normalizedId.includes("/@tanstack/start-server-core/dist/esm/request-response.js");
|
|
197
|
+
if (!isTargetModule) {
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
const needle = "handler(request, requestOpts)";
|
|
201
|
+
if (!code.includes(needle)) {
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
204
|
+
return code.replace(
|
|
205
|
+
needle,
|
|
206
|
+
`Promise.resolve(${needle}).catch((err) => { globalThis.${SSR_CAPTURE_KEY}?.(err); throw err; })`
|
|
207
|
+
);
|
|
191
208
|
}
|
|
192
209
|
};
|
|
193
210
|
}
|
|
@@ -249,7 +266,7 @@ function defineConfig(configOrOptions = {}) {
|
|
|
249
266
|
options = { vite: await configOrOptions };
|
|
250
267
|
} else {
|
|
251
268
|
const optionObject = configOrOptions && typeof configOrOptions === "object" ? configOrOptions : {};
|
|
252
|
-
const hasLovableKey = "vite" in optionObject || "serverFnErrorLogger" in optionObject || "ssrErrorLogger" in optionObject || "
|
|
269
|
+
const hasLovableKey = "vite" in optionObject || "serverFnErrorLogger" in optionObject || "ssrErrorLogger" in optionObject || "nitro" in optionObject || "tanstackStart" in optionObject || "react" in optionObject || "envDefine" in optionObject || "hmrGate" in optionObject;
|
|
253
270
|
options = hasLovableKey ? optionObject : { vite: optionObject };
|
|
254
271
|
}
|
|
255
272
|
const internalPlugins = [];
|
|
@@ -263,16 +280,6 @@ function defineConfig(configOrOptions = {}) {
|
|
|
263
280
|
if (options.ssrErrorLogger !== false) {
|
|
264
281
|
internalPlugins.push(devSsrErrorLogger());
|
|
265
282
|
}
|
|
266
|
-
if (options.cloudflare !== false && command === "build") {
|
|
267
|
-
try {
|
|
268
|
-
const { cloudflare } = await import("@cloudflare/vite-plugin");
|
|
269
|
-
const cfOptions = typeof options.cloudflare === "object" && options.cloudflare || {
|
|
270
|
-
viteEnvironment: { name: "ssr" }
|
|
271
|
-
};
|
|
272
|
-
internalPlugins.push(cloudflare(cfOptions));
|
|
273
|
-
} catch {
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
283
|
const { tanstackStart } = await import("@tanstack/react-start/plugin/vite");
|
|
277
284
|
const tanstackStartDefaults = {
|
|
278
285
|
importProtection: {
|
|
@@ -285,6 +292,17 @@ function defineConfig(configOrOptions = {}) {
|
|
|
285
292
|
};
|
|
286
293
|
const tanstackStartOptions = (0, import_vite.mergeConfig)(tanstackStartDefaults, options.tanstackStart ?? {});
|
|
287
294
|
internalPlugins.push(tanstackStart(tanstackStartOptions));
|
|
295
|
+
if (options.nitro !== false && command === "build") {
|
|
296
|
+
try {
|
|
297
|
+
const { nitro } = await import("nitro/vite");
|
|
298
|
+
const userNitroOpts = typeof options.nitro === "object" && options.nitro ? options.nitro : {};
|
|
299
|
+
const preset = userNitroOpts.preset ?? process.env.NITRO_PRESET ?? "cloudflare-module";
|
|
300
|
+
const userOutput = typeof userNitroOpts.output === "object" && userNitroOpts.output ? userNitroOpts.output : {};
|
|
301
|
+
const output = { dir: "dist", ...userOutput };
|
|
302
|
+
internalPlugins.push(nitro({ config: { ...userNitroOpts, preset, output } }));
|
|
303
|
+
} catch {
|
|
304
|
+
}
|
|
305
|
+
}
|
|
288
306
|
const viteReact = (await import("@vitejs/plugin-react")).default;
|
|
289
307
|
internalPlugins.push(viteReact(options.react));
|
|
290
308
|
if (command === "serve") {
|
package/dist/index.d.cts
CHANGED
|
@@ -5,7 +5,13 @@ interface LovableViteTanstackOptions {
|
|
|
5
5
|
vite?: UserConfig;
|
|
6
6
|
serverFnErrorLogger?: boolean;
|
|
7
7
|
ssrErrorLogger?: boolean;
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Options forwarded to `nitro()` from `nitro/vite`. Set to `false` to skip
|
|
10
|
+
* the Nitro build plugin entirely (e.g. when the surrounding tanstackStart
|
|
11
|
+
* version already delegates to Nitro internally). The deploy preset is
|
|
12
|
+
* selected via `NITRO_PRESET` env var or `nitro.preset` here.
|
|
13
|
+
*/
|
|
14
|
+
nitro?: Record<string, unknown> | false;
|
|
9
15
|
/** Options forwarded to tanstackStart(). */
|
|
10
16
|
tanstackStart?: Record<string, unknown>;
|
|
11
17
|
/** Options forwarded to viteReact(). */
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,13 @@ interface LovableViteTanstackOptions {
|
|
|
5
5
|
vite?: UserConfig;
|
|
6
6
|
serverFnErrorLogger?: boolean;
|
|
7
7
|
ssrErrorLogger?: boolean;
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Options forwarded to `nitro()` from `nitro/vite`. Set to `false` to skip
|
|
10
|
+
* the Nitro build plugin entirely (e.g. when the surrounding tanstackStart
|
|
11
|
+
* version already delegates to Nitro internally). The deploy preset is
|
|
12
|
+
* selected via `NITRO_PRESET` env var or `nitro.preset` here.
|
|
13
|
+
*/
|
|
14
|
+
nitro?: Record<string, unknown> | false;
|
|
9
15
|
/** Options forwarded to tanstackStart(). */
|
|
10
16
|
tanstackStart?: Record<string, unknown>;
|
|
11
17
|
/** Options forwarded to viteReact(). */
|
package/dist/index.js
CHANGED
|
@@ -96,6 +96,7 @@ function applyWatchDebounceDefaults(config) {
|
|
|
96
96
|
}
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
|
+
var SSR_CAPTURE_KEY = "__LOVABLE_TANSTACK_CAPTURE_SSR_ERROR__";
|
|
99
100
|
function devSsrErrorLogger() {
|
|
100
101
|
let lastCapture;
|
|
101
102
|
const CAPTURE_TTL_MS = 5e3;
|
|
@@ -117,6 +118,7 @@ function devSsrErrorLogger() {
|
|
|
117
118
|
name: "dev-ssr-error-logger",
|
|
118
119
|
apply: "serve",
|
|
119
120
|
configureServer(server) {
|
|
121
|
+
globalThis[SSR_CAPTURE_KEY] = capture;
|
|
120
122
|
const g = globalThis;
|
|
121
123
|
if (typeof g.addEventListener === "function") {
|
|
122
124
|
const addListener = g.addEventListener;
|
|
@@ -154,6 +156,21 @@ function devSsrErrorLogger() {
|
|
|
154
156
|
};
|
|
155
157
|
next();
|
|
156
158
|
});
|
|
159
|
+
},
|
|
160
|
+
transform(code, id) {
|
|
161
|
+
const normalizedId = id.replace(/\\/g, "/");
|
|
162
|
+
const isTargetModule = normalizedId.includes("/@tanstack/start-server-core/src/request-response.ts") || normalizedId.includes("/@tanstack/start-server-core/dist/esm/request-response.js");
|
|
163
|
+
if (!isTargetModule) {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
const needle = "handler(request, requestOpts)";
|
|
167
|
+
if (!code.includes(needle)) {
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
return code.replace(
|
|
171
|
+
needle,
|
|
172
|
+
`Promise.resolve(${needle}).catch((err) => { globalThis.${SSR_CAPTURE_KEY}?.(err); throw err; })`
|
|
173
|
+
);
|
|
157
174
|
}
|
|
158
175
|
};
|
|
159
176
|
}
|
|
@@ -215,7 +232,7 @@ function defineConfig(configOrOptions = {}) {
|
|
|
215
232
|
options = { vite: await configOrOptions };
|
|
216
233
|
} else {
|
|
217
234
|
const optionObject = configOrOptions && typeof configOrOptions === "object" ? configOrOptions : {};
|
|
218
|
-
const hasLovableKey = "vite" in optionObject || "serverFnErrorLogger" in optionObject || "ssrErrorLogger" in optionObject || "
|
|
235
|
+
const hasLovableKey = "vite" in optionObject || "serverFnErrorLogger" in optionObject || "ssrErrorLogger" in optionObject || "nitro" in optionObject || "tanstackStart" in optionObject || "react" in optionObject || "envDefine" in optionObject || "hmrGate" in optionObject;
|
|
219
236
|
options = hasLovableKey ? optionObject : { vite: optionObject };
|
|
220
237
|
}
|
|
221
238
|
const internalPlugins = [];
|
|
@@ -229,16 +246,6 @@ function defineConfig(configOrOptions = {}) {
|
|
|
229
246
|
if (options.ssrErrorLogger !== false) {
|
|
230
247
|
internalPlugins.push(devSsrErrorLogger());
|
|
231
248
|
}
|
|
232
|
-
if (options.cloudflare !== false && command === "build") {
|
|
233
|
-
try {
|
|
234
|
-
const { cloudflare } = await import("@cloudflare/vite-plugin");
|
|
235
|
-
const cfOptions = typeof options.cloudflare === "object" && options.cloudflare || {
|
|
236
|
-
viteEnvironment: { name: "ssr" }
|
|
237
|
-
};
|
|
238
|
-
internalPlugins.push(cloudflare(cfOptions));
|
|
239
|
-
} catch {
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
249
|
const { tanstackStart } = await import("@tanstack/react-start/plugin/vite");
|
|
243
250
|
const tanstackStartDefaults = {
|
|
244
251
|
importProtection: {
|
|
@@ -251,6 +258,17 @@ function defineConfig(configOrOptions = {}) {
|
|
|
251
258
|
};
|
|
252
259
|
const tanstackStartOptions = mergeConfig(tanstackStartDefaults, options.tanstackStart ?? {});
|
|
253
260
|
internalPlugins.push(tanstackStart(tanstackStartOptions));
|
|
261
|
+
if (options.nitro !== false && command === "build") {
|
|
262
|
+
try {
|
|
263
|
+
const { nitro } = await import("nitro/vite");
|
|
264
|
+
const userNitroOpts = typeof options.nitro === "object" && options.nitro ? options.nitro : {};
|
|
265
|
+
const preset = userNitroOpts.preset ?? process.env.NITRO_PRESET ?? "cloudflare-module";
|
|
266
|
+
const userOutput = typeof userNitroOpts.output === "object" && userNitroOpts.output ? userNitroOpts.output : {};
|
|
267
|
+
const output = { dir: "dist", ...userOutput };
|
|
268
|
+
internalPlugins.push(nitro({ config: { ...userNitroOpts, preset, output } }));
|
|
269
|
+
} catch {
|
|
270
|
+
}
|
|
271
|
+
}
|
|
254
272
|
const viteReact = (await import("@vitejs/plugin-react")).default;
|
|
255
273
|
internalPlugins.push(viteReact(options.react));
|
|
256
274
|
if (command === "serve") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lovable.dev/vite-tanstack-config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-rc.0",
|
|
4
4
|
"description": "Vite config wrapper for Lovable TanStack Start projects",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -9,15 +9,6 @@
|
|
|
9
9
|
"files": [
|
|
10
10
|
"dist"
|
|
11
11
|
],
|
|
12
|
-
"scripts": {
|
|
13
|
-
"build": "tsup src/index.ts --format cjs,esm --dts --outDir dist",
|
|
14
|
-
"typecheck": "tsgo --noEmit",
|
|
15
|
-
"dev": "tsup src/index.ts --format cjs,esm --dts --watch",
|
|
16
|
-
"test": "vitest",
|
|
17
|
-
"prepublishOnly": "npm run clean && npm run build",
|
|
18
|
-
"clean": "rimraf dist",
|
|
19
|
-
"coverage": "vitest run --coverage"
|
|
20
|
-
},
|
|
21
12
|
"keywords": [
|
|
22
13
|
"vite",
|
|
23
14
|
"tanstack",
|
|
@@ -34,26 +25,34 @@
|
|
|
34
25
|
"vite": ">=5.0.0 <9.0.0",
|
|
35
26
|
"@tailwindcss/vite": ">=4.0.0",
|
|
36
27
|
"vite-tsconfig-paths": ">=6.0.0",
|
|
37
|
-
"
|
|
28
|
+
"nitro": "^3.0.0",
|
|
38
29
|
"@tanstack/react-start": ">=1.100.0",
|
|
39
30
|
"@vitejs/plugin-react": ">=4.0.0"
|
|
40
31
|
},
|
|
41
32
|
"peerDependenciesMeta": {
|
|
42
|
-
"
|
|
33
|
+
"nitro": {
|
|
43
34
|
"optional": true
|
|
44
35
|
}
|
|
45
36
|
},
|
|
46
37
|
"devDependencies": {
|
|
47
|
-
"
|
|
38
|
+
"nitro": "3.0.0",
|
|
48
39
|
"@tanstack/react-start": "^1.162.9",
|
|
49
40
|
"@vitejs/plugin-react": "^4.5.2",
|
|
50
41
|
"@tailwindcss/vite": "^4.2.1",
|
|
51
|
-
"@types/node": "
|
|
42
|
+
"@types/node": "22.13.13",
|
|
52
43
|
"rimraf": "^5.0.0",
|
|
53
44
|
"tsup": "^7.2.0",
|
|
54
|
-
"typescript": "
|
|
45
|
+
"typescript": "^5.9.3",
|
|
55
46
|
"vite": "^7.3.1",
|
|
56
47
|
"vite-tsconfig-paths": "^6.0.2",
|
|
57
|
-
"vitest": "
|
|
48
|
+
"vitest": "^4.1.5"
|
|
49
|
+
},
|
|
50
|
+
"scripts": {
|
|
51
|
+
"build": "tsup src/index.ts --format cjs,esm --dts --outDir dist",
|
|
52
|
+
"typecheck": "tsgo --noEmit",
|
|
53
|
+
"dev": "tsup src/index.ts --format cjs,esm --dts --watch",
|
|
54
|
+
"test": "vitest",
|
|
55
|
+
"clean": "rimraf dist",
|
|
56
|
+
"coverage": "vitest run --coverage"
|
|
58
57
|
}
|
|
59
|
-
}
|
|
58
|
+
}
|