@lovable.dev/vite-tanstack-config 2.5.3 → 2.5.4-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 +120 -0
- package/dist/index.js +120 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -175,6 +175,123 @@ 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
|
+
"stack",
|
|
194
|
+
"cause"
|
|
195
|
+
];
|
|
196
|
+
function truncateDiagnosticString(value) {
|
|
197
|
+
return value.length > MAX_DIAGNOSTIC_STRING_LENGTH ? `${value.slice(0, MAX_DIAGNOSTIC_STRING_LENGTH)}...[truncated]` : value;
|
|
198
|
+
}
|
|
199
|
+
function readDiagnosticProperty(value, key) {
|
|
200
|
+
try {
|
|
201
|
+
return value[key];
|
|
202
|
+
} catch (error) {
|
|
203
|
+
return `[unreadable: ${error instanceof Error ? error.message : String(error)}]`;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
function serializeOwnDiagnosticProperties(value, depth, seen) {
|
|
207
|
+
const keys = Object.keys(value);
|
|
208
|
+
const output = {};
|
|
209
|
+
for (const key of keys.slice(0, MAX_DIAGNOSTIC_NESTED_ERRORS)) {
|
|
210
|
+
const nested = readDiagnosticProperty(value, key);
|
|
211
|
+
if (nested == null || nested === "")
|
|
212
|
+
continue;
|
|
213
|
+
output[key] = serializeDiagnosticValue(nested, depth + 1, seen);
|
|
214
|
+
}
|
|
215
|
+
if (keys.length > MAX_DIAGNOSTIC_NESTED_ERRORS) {
|
|
216
|
+
output.properties_truncated = keys.length - MAX_DIAGNOSTIC_NESTED_ERRORS;
|
|
217
|
+
}
|
|
218
|
+
return output;
|
|
219
|
+
}
|
|
220
|
+
function describeDiagnosticPrimitive(value) {
|
|
221
|
+
if (typeof value === "symbol")
|
|
222
|
+
return value.description ? `Symbol(${value.description})` : "Symbol()";
|
|
223
|
+
if (typeof value === "bigint")
|
|
224
|
+
return value.toString();
|
|
225
|
+
if (typeof value === "function")
|
|
226
|
+
return `[function ${value.name || "anonymous"}]`;
|
|
227
|
+
return String(value);
|
|
228
|
+
}
|
|
229
|
+
function describeDiagnosticObject(value) {
|
|
230
|
+
const constructorName = value.constructor?.name;
|
|
231
|
+
if (typeof constructorName === "string" && constructorName !== "" && constructorName !== "Object") {
|
|
232
|
+
return `[${constructorName}]`;
|
|
233
|
+
}
|
|
234
|
+
return Object.prototype.toString.call(value);
|
|
235
|
+
}
|
|
236
|
+
function serializeDiagnosticValue(value, depth, seen) {
|
|
237
|
+
if (value == null)
|
|
238
|
+
return value;
|
|
239
|
+
if (typeof value === "string")
|
|
240
|
+
return truncateDiagnosticString(value);
|
|
241
|
+
if (typeof value === "number" || typeof value === "boolean")
|
|
242
|
+
return value;
|
|
243
|
+
if (typeof value !== "object")
|
|
244
|
+
return describeDiagnosticPrimitive(value);
|
|
245
|
+
if (seen.has(value))
|
|
246
|
+
return "[circular]";
|
|
247
|
+
if (depth >= MAX_DIAGNOSTIC_DEPTH)
|
|
248
|
+
return "[max depth]";
|
|
249
|
+
seen.add(value);
|
|
250
|
+
try {
|
|
251
|
+
if (Array.isArray(value)) {
|
|
252
|
+
return value.slice(0, MAX_DIAGNOSTIC_NESTED_ERRORS).map((item) => serializeDiagnosticValue(item, depth + 1, seen));
|
|
253
|
+
}
|
|
254
|
+
const record = value;
|
|
255
|
+
const output = {};
|
|
256
|
+
for (const field of DIAGNOSTIC_ERROR_FIELDS) {
|
|
257
|
+
if (!(field in record))
|
|
258
|
+
continue;
|
|
259
|
+
const nested = readDiagnosticProperty(record, field);
|
|
260
|
+
if (nested == null || nested === "")
|
|
261
|
+
continue;
|
|
262
|
+
output[field] = serializeDiagnosticValue(nested, depth + 1, seen);
|
|
263
|
+
}
|
|
264
|
+
const nestedErrors = readDiagnosticProperty(record, "errors");
|
|
265
|
+
if (Array.isArray(nestedErrors)) {
|
|
266
|
+
output.errors = nestedErrors.slice(0, MAX_DIAGNOSTIC_NESTED_ERRORS).map((item) => serializeDiagnosticValue(item, depth + 1, seen));
|
|
267
|
+
if (nestedErrors.length > MAX_DIAGNOSTIC_NESTED_ERRORS) {
|
|
268
|
+
output.errors_truncated = nestedErrors.length - MAX_DIAGNOSTIC_NESTED_ERRORS;
|
|
269
|
+
}
|
|
270
|
+
} else if (nestedErrors != null && nestedErrors !== "") {
|
|
271
|
+
output.errors = serializeDiagnosticValue(nestedErrors, depth + 1, seen);
|
|
272
|
+
}
|
|
273
|
+
if (Object.keys(output).length > 0)
|
|
274
|
+
return output;
|
|
275
|
+
const ownProperties = serializeOwnDiagnosticProperties(record, depth, seen);
|
|
276
|
+
return Object.keys(ownProperties).length > 0 ? ownProperties : describeDiagnosticObject(value);
|
|
277
|
+
} finally {
|
|
278
|
+
seen.delete(value);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
function lovableBuildErrorDiagnostics() {
|
|
282
|
+
return {
|
|
283
|
+
name: BUILD_DIAGNOSTICS_PLUGIN_NAME,
|
|
284
|
+
apply: "build",
|
|
285
|
+
buildEnd(error) {
|
|
286
|
+
if (!error)
|
|
287
|
+
return;
|
|
288
|
+
const diagnostics = serializeDiagnosticValue(error, 0, /* @__PURE__ */ new WeakSet());
|
|
289
|
+
console.error("\n[lovable-build-error-diagnostics]");
|
|
290
|
+
console.error(JSON.stringify(diagnostics, null, 2));
|
|
291
|
+
console.error("[/lovable-build-error-diagnostics]");
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
}
|
|
178
295
|
function devSsrErrorLogger() {
|
|
179
296
|
let lastCapture;
|
|
180
297
|
const CAPTURE_TTL_MS = 5e3;
|
|
@@ -373,6 +490,9 @@ function defineConfig(configOrOptions = {}) {
|
|
|
373
490
|
if (options.ssrErrorLogger !== false) {
|
|
374
491
|
internalPlugins.push(devSsrErrorLogger());
|
|
375
492
|
}
|
|
493
|
+
if (command === "build" && isSandbox) {
|
|
494
|
+
internalPlugins.push(lovableBuildErrorDiagnostics());
|
|
495
|
+
}
|
|
376
496
|
const { tanstackStart } = await import("@tanstack/react-start/plugin/vite");
|
|
377
497
|
const tanstackStartDefaults = {
|
|
378
498
|
importProtection: {
|
package/dist/index.js
CHANGED
|
@@ -141,6 +141,123 @@ 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
|
+
"stack",
|
|
160
|
+
"cause"
|
|
161
|
+
];
|
|
162
|
+
function truncateDiagnosticString(value) {
|
|
163
|
+
return value.length > MAX_DIAGNOSTIC_STRING_LENGTH ? `${value.slice(0, MAX_DIAGNOSTIC_STRING_LENGTH)}...[truncated]` : value;
|
|
164
|
+
}
|
|
165
|
+
function readDiagnosticProperty(value, key) {
|
|
166
|
+
try {
|
|
167
|
+
return value[key];
|
|
168
|
+
} catch (error) {
|
|
169
|
+
return `[unreadable: ${error instanceof Error ? error.message : String(error)}]`;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
function serializeOwnDiagnosticProperties(value, depth, seen) {
|
|
173
|
+
const keys = Object.keys(value);
|
|
174
|
+
const output = {};
|
|
175
|
+
for (const key of keys.slice(0, MAX_DIAGNOSTIC_NESTED_ERRORS)) {
|
|
176
|
+
const nested = readDiagnosticProperty(value, key);
|
|
177
|
+
if (nested == null || nested === "")
|
|
178
|
+
continue;
|
|
179
|
+
output[key] = serializeDiagnosticValue(nested, depth + 1, seen);
|
|
180
|
+
}
|
|
181
|
+
if (keys.length > MAX_DIAGNOSTIC_NESTED_ERRORS) {
|
|
182
|
+
output.properties_truncated = keys.length - MAX_DIAGNOSTIC_NESTED_ERRORS;
|
|
183
|
+
}
|
|
184
|
+
return output;
|
|
185
|
+
}
|
|
186
|
+
function describeDiagnosticPrimitive(value) {
|
|
187
|
+
if (typeof value === "symbol")
|
|
188
|
+
return value.description ? `Symbol(${value.description})` : "Symbol()";
|
|
189
|
+
if (typeof value === "bigint")
|
|
190
|
+
return value.toString();
|
|
191
|
+
if (typeof value === "function")
|
|
192
|
+
return `[function ${value.name || "anonymous"}]`;
|
|
193
|
+
return String(value);
|
|
194
|
+
}
|
|
195
|
+
function describeDiagnosticObject(value) {
|
|
196
|
+
const constructorName = value.constructor?.name;
|
|
197
|
+
if (typeof constructorName === "string" && constructorName !== "" && constructorName !== "Object") {
|
|
198
|
+
return `[${constructorName}]`;
|
|
199
|
+
}
|
|
200
|
+
return Object.prototype.toString.call(value);
|
|
201
|
+
}
|
|
202
|
+
function serializeDiagnosticValue(value, depth, seen) {
|
|
203
|
+
if (value == null)
|
|
204
|
+
return value;
|
|
205
|
+
if (typeof value === "string")
|
|
206
|
+
return truncateDiagnosticString(value);
|
|
207
|
+
if (typeof value === "number" || typeof value === "boolean")
|
|
208
|
+
return value;
|
|
209
|
+
if (typeof value !== "object")
|
|
210
|
+
return describeDiagnosticPrimitive(value);
|
|
211
|
+
if (seen.has(value))
|
|
212
|
+
return "[circular]";
|
|
213
|
+
if (depth >= MAX_DIAGNOSTIC_DEPTH)
|
|
214
|
+
return "[max depth]";
|
|
215
|
+
seen.add(value);
|
|
216
|
+
try {
|
|
217
|
+
if (Array.isArray(value)) {
|
|
218
|
+
return value.slice(0, MAX_DIAGNOSTIC_NESTED_ERRORS).map((item) => serializeDiagnosticValue(item, depth + 1, seen));
|
|
219
|
+
}
|
|
220
|
+
const record = value;
|
|
221
|
+
const output = {};
|
|
222
|
+
for (const field of DIAGNOSTIC_ERROR_FIELDS) {
|
|
223
|
+
if (!(field in record))
|
|
224
|
+
continue;
|
|
225
|
+
const nested = readDiagnosticProperty(record, field);
|
|
226
|
+
if (nested == null || nested === "")
|
|
227
|
+
continue;
|
|
228
|
+
output[field] = serializeDiagnosticValue(nested, depth + 1, seen);
|
|
229
|
+
}
|
|
230
|
+
const nestedErrors = readDiagnosticProperty(record, "errors");
|
|
231
|
+
if (Array.isArray(nestedErrors)) {
|
|
232
|
+
output.errors = nestedErrors.slice(0, MAX_DIAGNOSTIC_NESTED_ERRORS).map((item) => serializeDiagnosticValue(item, depth + 1, seen));
|
|
233
|
+
if (nestedErrors.length > MAX_DIAGNOSTIC_NESTED_ERRORS) {
|
|
234
|
+
output.errors_truncated = nestedErrors.length - MAX_DIAGNOSTIC_NESTED_ERRORS;
|
|
235
|
+
}
|
|
236
|
+
} else if (nestedErrors != null && nestedErrors !== "") {
|
|
237
|
+
output.errors = serializeDiagnosticValue(nestedErrors, depth + 1, seen);
|
|
238
|
+
}
|
|
239
|
+
if (Object.keys(output).length > 0)
|
|
240
|
+
return output;
|
|
241
|
+
const ownProperties = serializeOwnDiagnosticProperties(record, depth, seen);
|
|
242
|
+
return Object.keys(ownProperties).length > 0 ? ownProperties : describeDiagnosticObject(value);
|
|
243
|
+
} finally {
|
|
244
|
+
seen.delete(value);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
function lovableBuildErrorDiagnostics() {
|
|
248
|
+
return {
|
|
249
|
+
name: BUILD_DIAGNOSTICS_PLUGIN_NAME,
|
|
250
|
+
apply: "build",
|
|
251
|
+
buildEnd(error) {
|
|
252
|
+
if (!error)
|
|
253
|
+
return;
|
|
254
|
+
const diagnostics = serializeDiagnosticValue(error, 0, /* @__PURE__ */ new WeakSet());
|
|
255
|
+
console.error("\n[lovable-build-error-diagnostics]");
|
|
256
|
+
console.error(JSON.stringify(diagnostics, null, 2));
|
|
257
|
+
console.error("[/lovable-build-error-diagnostics]");
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
}
|
|
144
261
|
function devSsrErrorLogger() {
|
|
145
262
|
let lastCapture;
|
|
146
263
|
const CAPTURE_TTL_MS = 5e3;
|
|
@@ -339,6 +456,9 @@ function defineConfig(configOrOptions = {}) {
|
|
|
339
456
|
if (options.ssrErrorLogger !== false) {
|
|
340
457
|
internalPlugins.push(devSsrErrorLogger());
|
|
341
458
|
}
|
|
459
|
+
if (command === "build" && isSandbox) {
|
|
460
|
+
internalPlugins.push(lovableBuildErrorDiagnostics());
|
|
461
|
+
}
|
|
342
462
|
const { tanstackStart } = await import("@tanstack/react-start/plugin/vite");
|
|
343
463
|
const tanstackStartDefaults = {
|
|
344
464
|
importProtection: {
|