@lovable.dev/vite-tanstack-config 2.5.4-rc.1 → 2.6.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 +1 -136
- package/dist/index.d.cts +7 -8
- package/dist/index.d.ts +7 -8
- package/dist/index.js +1 -136
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -175,133 +175,6 @@ function isBuildError(error) {
|
|
|
175
175
|
const message = typeof e.message === "string" ? e.message : "";
|
|
176
176
|
return BUILD_ERROR_MESSAGE.test(message);
|
|
177
177
|
}
|
|
178
|
-
var BUILD_DIAGNOSTICS_PLUGIN_NAME = "lovable-build-error-diagnostics";
|
|
179
|
-
var MAX_DIAGNOSTIC_STRING_LENGTH = 2e3;
|
|
180
|
-
var MAX_DIAGNOSTIC_NESTED_ERRORS = 20;
|
|
181
|
-
var MAX_DIAGNOSTIC_DEPTH = 4;
|
|
182
|
-
var DIAGNOSTIC_ERROR_FIELDS = [
|
|
183
|
-
"name",
|
|
184
|
-
"message",
|
|
185
|
-
"plugin",
|
|
186
|
-
"pluginCode",
|
|
187
|
-
"id",
|
|
188
|
-
"moduleId",
|
|
189
|
-
"hook",
|
|
190
|
-
"code",
|
|
191
|
-
"loc",
|
|
192
|
-
"frame",
|
|
193
|
-
"cause"
|
|
194
|
-
];
|
|
195
|
-
function truncateDiagnosticString(value) {
|
|
196
|
-
return value.length > MAX_DIAGNOSTIC_STRING_LENGTH ? `${value.slice(0, MAX_DIAGNOSTIC_STRING_LENGTH)}...[truncated]` : value;
|
|
197
|
-
}
|
|
198
|
-
function readDiagnosticProperty(value, key) {
|
|
199
|
-
try {
|
|
200
|
-
return value[key];
|
|
201
|
-
} catch (error) {
|
|
202
|
-
return `[unreadable: ${error instanceof Error ? error.message : String(error)}]`;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
function serializeOwnDiagnosticProperties(value, depth, seen) {
|
|
206
|
-
const keys = Object.keys(value);
|
|
207
|
-
const output = {};
|
|
208
|
-
for (const key of keys.slice(0, MAX_DIAGNOSTIC_NESTED_ERRORS)) {
|
|
209
|
-
const nested = readDiagnosticProperty(value, key);
|
|
210
|
-
if (nested == null || nested === "")
|
|
211
|
-
continue;
|
|
212
|
-
output[key] = serializeDiagnosticValue(nested, depth + 1, seen);
|
|
213
|
-
}
|
|
214
|
-
if (keys.length > MAX_DIAGNOSTIC_NESTED_ERRORS) {
|
|
215
|
-
output.properties_truncated = keys.length - MAX_DIAGNOSTIC_NESTED_ERRORS;
|
|
216
|
-
}
|
|
217
|
-
return output;
|
|
218
|
-
}
|
|
219
|
-
function describeDiagnosticPrimitive(value) {
|
|
220
|
-
if (typeof value === "symbol")
|
|
221
|
-
return value.description ? `Symbol(${value.description})` : "Symbol()";
|
|
222
|
-
if (typeof value === "bigint")
|
|
223
|
-
return value.toString();
|
|
224
|
-
if (typeof value === "function")
|
|
225
|
-
return `[function ${value.name || "anonymous"}]`;
|
|
226
|
-
return String(value);
|
|
227
|
-
}
|
|
228
|
-
function describeDiagnosticObject(value) {
|
|
229
|
-
const constructorName = value.constructor?.name;
|
|
230
|
-
if (typeof constructorName === "string" && constructorName !== "" && constructorName !== "Object") {
|
|
231
|
-
return `[${constructorName}]`;
|
|
232
|
-
}
|
|
233
|
-
return Object.prototype.toString.call(value);
|
|
234
|
-
}
|
|
235
|
-
function serializeDiagnosticValue(value, depth, seen) {
|
|
236
|
-
if (value == null)
|
|
237
|
-
return value;
|
|
238
|
-
if (typeof value === "string")
|
|
239
|
-
return truncateDiagnosticString(value);
|
|
240
|
-
if (typeof value === "number" || typeof value === "boolean")
|
|
241
|
-
return value;
|
|
242
|
-
if (typeof value !== "object")
|
|
243
|
-
return describeDiagnosticPrimitive(value);
|
|
244
|
-
if (seen.has(value))
|
|
245
|
-
return "[circular]";
|
|
246
|
-
if (depth >= MAX_DIAGNOSTIC_DEPTH)
|
|
247
|
-
return "[max depth]";
|
|
248
|
-
seen.add(value);
|
|
249
|
-
try {
|
|
250
|
-
if (Array.isArray(value)) {
|
|
251
|
-
return value.slice(0, MAX_DIAGNOSTIC_NESTED_ERRORS).map((item) => serializeDiagnosticValue(item, depth + 1, seen));
|
|
252
|
-
}
|
|
253
|
-
const record = value;
|
|
254
|
-
const output = {};
|
|
255
|
-
for (const field of DIAGNOSTIC_ERROR_FIELDS) {
|
|
256
|
-
if (!(field in record))
|
|
257
|
-
continue;
|
|
258
|
-
const nested = readDiagnosticProperty(record, field);
|
|
259
|
-
if (nested == null || nested === "")
|
|
260
|
-
continue;
|
|
261
|
-
output[field] = serializeDiagnosticValue(nested, depth + 1, seen);
|
|
262
|
-
}
|
|
263
|
-
const nestedErrors = readDiagnosticProperty(record, "errors");
|
|
264
|
-
if (Array.isArray(nestedErrors)) {
|
|
265
|
-
output.errors = nestedErrors.slice(0, MAX_DIAGNOSTIC_NESTED_ERRORS).map((item) => serializeDiagnosticValue(item, depth + 1, seen));
|
|
266
|
-
if (nestedErrors.length > MAX_DIAGNOSTIC_NESTED_ERRORS) {
|
|
267
|
-
output.errors_truncated = nestedErrors.length - MAX_DIAGNOSTIC_NESTED_ERRORS;
|
|
268
|
-
}
|
|
269
|
-
} else if (nestedErrors != null && nestedErrors !== "") {
|
|
270
|
-
output.errors = serializeDiagnosticValue(nestedErrors, depth + 1, seen);
|
|
271
|
-
}
|
|
272
|
-
if (Object.keys(output).length > 0)
|
|
273
|
-
return output;
|
|
274
|
-
const ownProperties = serializeOwnDiagnosticProperties(record, depth, seen);
|
|
275
|
-
return Object.keys(ownProperties).length > 0 ? ownProperties : describeDiagnosticObject(value);
|
|
276
|
-
} finally {
|
|
277
|
-
seen.delete(value);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
function lovableBuildErrorDiagnostics() {
|
|
281
|
-
return {
|
|
282
|
-
name: BUILD_DIAGNOSTICS_PLUGIN_NAME,
|
|
283
|
-
apply: "build",
|
|
284
|
-
buildEnd(error) {
|
|
285
|
-
if (!error)
|
|
286
|
-
return;
|
|
287
|
-
const diagnostics = serializeDiagnosticValue(error, 0, /* @__PURE__ */ new WeakSet());
|
|
288
|
-
const output = `
|
|
289
|
-
[lovable-build-error-diagnostics]
|
|
290
|
-
${JSON.stringify(diagnostics)}
|
|
291
|
-
[/lovable-build-error-diagnostics]
|
|
292
|
-
`;
|
|
293
|
-
let written = false;
|
|
294
|
-
const write = () => {
|
|
295
|
-
if (written)
|
|
296
|
-
return;
|
|
297
|
-
written = true;
|
|
298
|
-
process.stderr.write(output);
|
|
299
|
-
};
|
|
300
|
-
setImmediate(write);
|
|
301
|
-
process.once("exit", write);
|
|
302
|
-
}
|
|
303
|
-
};
|
|
304
|
-
}
|
|
305
178
|
function devSsrErrorLogger() {
|
|
306
179
|
let lastCapture;
|
|
307
180
|
const CAPTURE_TTL_MS = 5e3;
|
|
@@ -500,9 +373,6 @@ function defineConfig(configOrOptions = {}) {
|
|
|
500
373
|
if (options.ssrErrorLogger !== false) {
|
|
501
374
|
internalPlugins.push(devSsrErrorLogger());
|
|
502
375
|
}
|
|
503
|
-
if (command === "build" && isSandbox) {
|
|
504
|
-
internalPlugins.push(lovableBuildErrorDiagnostics());
|
|
505
|
-
}
|
|
506
376
|
const { tanstackStart } = await import("@tanstack/react-start/plugin/vite");
|
|
507
377
|
const tanstackStartDefaults = {
|
|
508
378
|
importProtection: {
|
|
@@ -516,12 +386,7 @@ function defineConfig(configOrOptions = {}) {
|
|
|
516
386
|
const tanstackStartOptions = (0, import_vite.mergeConfig)(tanstackStartDefaults, options.tanstackStart ?? {});
|
|
517
387
|
internalPlugins.push(tanstackStart(tanstackStartOptions));
|
|
518
388
|
const explicitNitro = options.nitro === true || typeof options.nitro === "object" && options.nitro !== null;
|
|
519
|
-
const shouldRunNitro = options.nitro !== false && command === "build"
|
|
520
|
-
if (options.nitro === void 0 && command === "build" && !isSandbox) {
|
|
521
|
-
console.info(
|
|
522
|
-
"[@lovable.dev/vite-tanstack-config] No Lovable context detected \u2014 skipping nitro deploy plugin. Pass `nitro: true` (or `nitro: { ... }`) to force-enable."
|
|
523
|
-
);
|
|
524
|
-
}
|
|
389
|
+
const shouldRunNitro = options.nitro !== false && command === "build";
|
|
525
390
|
if (shouldRunNitro) {
|
|
526
391
|
let nitroMod;
|
|
527
392
|
try {
|
package/dist/index.d.cts
CHANGED
|
@@ -9,14 +9,13 @@ interface LovableViteTanstackOptions {
|
|
|
9
9
|
* Options forwarded to `nitro()` from `nitro/vite`.
|
|
10
10
|
*
|
|
11
11
|
* Behavior:
|
|
12
|
-
* - **undefined** (default):
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* - **`true`**:
|
|
18
|
-
*
|
|
19
|
-
* (`NITRO_PRESET`, Vercel/Netlify/Cloudflare Pages) still wins.
|
|
12
|
+
* - **undefined** (default): nitro runs on every production build, defaulting
|
|
13
|
+
* to the `cloudflare-module` preset via Nitro's `defaultPreset` — zero-config
|
|
14
|
+
* target auto-detection (`NITRO_PRESET`, Vercel/Netlify/Cloudflare Pages)
|
|
15
|
+
* still wins, so a self-deploy auto-targets its own platform. If the optional
|
|
16
|
+
* `nitro` peer dep isn't installed, it's skipped (no deploy intent to honor).
|
|
17
|
+
* - **`true`**: same as undefined, but fails fast if the `nitro` peer dep is
|
|
18
|
+
* missing — the explicit opt-in signals deploy intent.
|
|
20
19
|
* - **object**: force-on, with these overrides. Set `preset`
|
|
21
20
|
* (e.g. `{ preset: "vercel" }`) to hard-pin a target from your own CI.
|
|
22
21
|
* - **`false`**: skip nitro entirely.
|
package/dist/index.d.ts
CHANGED
|
@@ -9,14 +9,13 @@ interface LovableViteTanstackOptions {
|
|
|
9
9
|
* Options forwarded to `nitro()` from `nitro/vite`.
|
|
10
10
|
*
|
|
11
11
|
* Behavior:
|
|
12
|
-
* - **undefined** (default):
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* - **`true`**:
|
|
18
|
-
*
|
|
19
|
-
* (`NITRO_PRESET`, Vercel/Netlify/Cloudflare Pages) still wins.
|
|
12
|
+
* - **undefined** (default): nitro runs on every production build, defaulting
|
|
13
|
+
* to the `cloudflare-module` preset via Nitro's `defaultPreset` — zero-config
|
|
14
|
+
* target auto-detection (`NITRO_PRESET`, Vercel/Netlify/Cloudflare Pages)
|
|
15
|
+
* still wins, so a self-deploy auto-targets its own platform. If the optional
|
|
16
|
+
* `nitro` peer dep isn't installed, it's skipped (no deploy intent to honor).
|
|
17
|
+
* - **`true`**: same as undefined, but fails fast if the `nitro` peer dep is
|
|
18
|
+
* missing — the explicit opt-in signals deploy intent.
|
|
20
19
|
* - **object**: force-on, with these overrides. Set `preset`
|
|
21
20
|
* (e.g. `{ preset: "vercel" }`) to hard-pin a target from your own CI.
|
|
22
21
|
* - **`false`**: skip nitro entirely.
|
package/dist/index.js
CHANGED
|
@@ -141,133 +141,6 @@ function isBuildError(error) {
|
|
|
141
141
|
const message = typeof e.message === "string" ? e.message : "";
|
|
142
142
|
return BUILD_ERROR_MESSAGE.test(message);
|
|
143
143
|
}
|
|
144
|
-
var BUILD_DIAGNOSTICS_PLUGIN_NAME = "lovable-build-error-diagnostics";
|
|
145
|
-
var MAX_DIAGNOSTIC_STRING_LENGTH = 2e3;
|
|
146
|
-
var MAX_DIAGNOSTIC_NESTED_ERRORS = 20;
|
|
147
|
-
var MAX_DIAGNOSTIC_DEPTH = 4;
|
|
148
|
-
var DIAGNOSTIC_ERROR_FIELDS = [
|
|
149
|
-
"name",
|
|
150
|
-
"message",
|
|
151
|
-
"plugin",
|
|
152
|
-
"pluginCode",
|
|
153
|
-
"id",
|
|
154
|
-
"moduleId",
|
|
155
|
-
"hook",
|
|
156
|
-
"code",
|
|
157
|
-
"loc",
|
|
158
|
-
"frame",
|
|
159
|
-
"cause"
|
|
160
|
-
];
|
|
161
|
-
function truncateDiagnosticString(value) {
|
|
162
|
-
return value.length > MAX_DIAGNOSTIC_STRING_LENGTH ? `${value.slice(0, MAX_DIAGNOSTIC_STRING_LENGTH)}...[truncated]` : value;
|
|
163
|
-
}
|
|
164
|
-
function readDiagnosticProperty(value, key) {
|
|
165
|
-
try {
|
|
166
|
-
return value[key];
|
|
167
|
-
} catch (error) {
|
|
168
|
-
return `[unreadable: ${error instanceof Error ? error.message : String(error)}]`;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
function serializeOwnDiagnosticProperties(value, depth, seen) {
|
|
172
|
-
const keys = Object.keys(value);
|
|
173
|
-
const output = {};
|
|
174
|
-
for (const key of keys.slice(0, MAX_DIAGNOSTIC_NESTED_ERRORS)) {
|
|
175
|
-
const nested = readDiagnosticProperty(value, key);
|
|
176
|
-
if (nested == null || nested === "")
|
|
177
|
-
continue;
|
|
178
|
-
output[key] = serializeDiagnosticValue(nested, depth + 1, seen);
|
|
179
|
-
}
|
|
180
|
-
if (keys.length > MAX_DIAGNOSTIC_NESTED_ERRORS) {
|
|
181
|
-
output.properties_truncated = keys.length - MAX_DIAGNOSTIC_NESTED_ERRORS;
|
|
182
|
-
}
|
|
183
|
-
return output;
|
|
184
|
-
}
|
|
185
|
-
function describeDiagnosticPrimitive(value) {
|
|
186
|
-
if (typeof value === "symbol")
|
|
187
|
-
return value.description ? `Symbol(${value.description})` : "Symbol()";
|
|
188
|
-
if (typeof value === "bigint")
|
|
189
|
-
return value.toString();
|
|
190
|
-
if (typeof value === "function")
|
|
191
|
-
return `[function ${value.name || "anonymous"}]`;
|
|
192
|
-
return String(value);
|
|
193
|
-
}
|
|
194
|
-
function describeDiagnosticObject(value) {
|
|
195
|
-
const constructorName = value.constructor?.name;
|
|
196
|
-
if (typeof constructorName === "string" && constructorName !== "" && constructorName !== "Object") {
|
|
197
|
-
return `[${constructorName}]`;
|
|
198
|
-
}
|
|
199
|
-
return Object.prototype.toString.call(value);
|
|
200
|
-
}
|
|
201
|
-
function serializeDiagnosticValue(value, depth, seen) {
|
|
202
|
-
if (value == null)
|
|
203
|
-
return value;
|
|
204
|
-
if (typeof value === "string")
|
|
205
|
-
return truncateDiagnosticString(value);
|
|
206
|
-
if (typeof value === "number" || typeof value === "boolean")
|
|
207
|
-
return value;
|
|
208
|
-
if (typeof value !== "object")
|
|
209
|
-
return describeDiagnosticPrimitive(value);
|
|
210
|
-
if (seen.has(value))
|
|
211
|
-
return "[circular]";
|
|
212
|
-
if (depth >= MAX_DIAGNOSTIC_DEPTH)
|
|
213
|
-
return "[max depth]";
|
|
214
|
-
seen.add(value);
|
|
215
|
-
try {
|
|
216
|
-
if (Array.isArray(value)) {
|
|
217
|
-
return value.slice(0, MAX_DIAGNOSTIC_NESTED_ERRORS).map((item) => serializeDiagnosticValue(item, depth + 1, seen));
|
|
218
|
-
}
|
|
219
|
-
const record = value;
|
|
220
|
-
const output = {};
|
|
221
|
-
for (const field of DIAGNOSTIC_ERROR_FIELDS) {
|
|
222
|
-
if (!(field in record))
|
|
223
|
-
continue;
|
|
224
|
-
const nested = readDiagnosticProperty(record, field);
|
|
225
|
-
if (nested == null || nested === "")
|
|
226
|
-
continue;
|
|
227
|
-
output[field] = serializeDiagnosticValue(nested, depth + 1, seen);
|
|
228
|
-
}
|
|
229
|
-
const nestedErrors = readDiagnosticProperty(record, "errors");
|
|
230
|
-
if (Array.isArray(nestedErrors)) {
|
|
231
|
-
output.errors = nestedErrors.slice(0, MAX_DIAGNOSTIC_NESTED_ERRORS).map((item) => serializeDiagnosticValue(item, depth + 1, seen));
|
|
232
|
-
if (nestedErrors.length > MAX_DIAGNOSTIC_NESTED_ERRORS) {
|
|
233
|
-
output.errors_truncated = nestedErrors.length - MAX_DIAGNOSTIC_NESTED_ERRORS;
|
|
234
|
-
}
|
|
235
|
-
} else if (nestedErrors != null && nestedErrors !== "") {
|
|
236
|
-
output.errors = serializeDiagnosticValue(nestedErrors, depth + 1, seen);
|
|
237
|
-
}
|
|
238
|
-
if (Object.keys(output).length > 0)
|
|
239
|
-
return output;
|
|
240
|
-
const ownProperties = serializeOwnDiagnosticProperties(record, depth, seen);
|
|
241
|
-
return Object.keys(ownProperties).length > 0 ? ownProperties : describeDiagnosticObject(value);
|
|
242
|
-
} finally {
|
|
243
|
-
seen.delete(value);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
function lovableBuildErrorDiagnostics() {
|
|
247
|
-
return {
|
|
248
|
-
name: BUILD_DIAGNOSTICS_PLUGIN_NAME,
|
|
249
|
-
apply: "build",
|
|
250
|
-
buildEnd(error) {
|
|
251
|
-
if (!error)
|
|
252
|
-
return;
|
|
253
|
-
const diagnostics = serializeDiagnosticValue(error, 0, /* @__PURE__ */ new WeakSet());
|
|
254
|
-
const output = `
|
|
255
|
-
[lovable-build-error-diagnostics]
|
|
256
|
-
${JSON.stringify(diagnostics)}
|
|
257
|
-
[/lovable-build-error-diagnostics]
|
|
258
|
-
`;
|
|
259
|
-
let written = false;
|
|
260
|
-
const write = () => {
|
|
261
|
-
if (written)
|
|
262
|
-
return;
|
|
263
|
-
written = true;
|
|
264
|
-
process.stderr.write(output);
|
|
265
|
-
};
|
|
266
|
-
setImmediate(write);
|
|
267
|
-
process.once("exit", write);
|
|
268
|
-
}
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
144
|
function devSsrErrorLogger() {
|
|
272
145
|
let lastCapture;
|
|
273
146
|
const CAPTURE_TTL_MS = 5e3;
|
|
@@ -466,9 +339,6 @@ function defineConfig(configOrOptions = {}) {
|
|
|
466
339
|
if (options.ssrErrorLogger !== false) {
|
|
467
340
|
internalPlugins.push(devSsrErrorLogger());
|
|
468
341
|
}
|
|
469
|
-
if (command === "build" && isSandbox) {
|
|
470
|
-
internalPlugins.push(lovableBuildErrorDiagnostics());
|
|
471
|
-
}
|
|
472
342
|
const { tanstackStart } = await import("@tanstack/react-start/plugin/vite");
|
|
473
343
|
const tanstackStartDefaults = {
|
|
474
344
|
importProtection: {
|
|
@@ -482,12 +352,7 @@ function defineConfig(configOrOptions = {}) {
|
|
|
482
352
|
const tanstackStartOptions = mergeConfig(tanstackStartDefaults, options.tanstackStart ?? {});
|
|
483
353
|
internalPlugins.push(tanstackStart(tanstackStartOptions));
|
|
484
354
|
const explicitNitro = options.nitro === true || typeof options.nitro === "object" && options.nitro !== null;
|
|
485
|
-
const shouldRunNitro = options.nitro !== false && command === "build"
|
|
486
|
-
if (options.nitro === void 0 && command === "build" && !isSandbox) {
|
|
487
|
-
console.info(
|
|
488
|
-
"[@lovable.dev/vite-tanstack-config] No Lovable context detected \u2014 skipping nitro deploy plugin. Pass `nitro: true` (or `nitro: { ... }`) to force-enable."
|
|
489
|
-
);
|
|
490
|
-
}
|
|
355
|
+
const shouldRunNitro = options.nitro !== false && command === "build";
|
|
491
356
|
if (shouldRunNitro) {
|
|
492
357
|
let nitroMod;
|
|
493
358
|
try {
|