@lovable.dev/vite-tanstack-config 2.5.3 → 2.5.4-rc.1
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 +130 -0
- package/dist/index.js +130 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -175,6 +175,133 @@ 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
|
+
}
|
|
178
305
|
function devSsrErrorLogger() {
|
|
179
306
|
let lastCapture;
|
|
180
307
|
const CAPTURE_TTL_MS = 5e3;
|
|
@@ -373,6 +500,9 @@ function defineConfig(configOrOptions = {}) {
|
|
|
373
500
|
if (options.ssrErrorLogger !== false) {
|
|
374
501
|
internalPlugins.push(devSsrErrorLogger());
|
|
375
502
|
}
|
|
503
|
+
if (command === "build" && isSandbox) {
|
|
504
|
+
internalPlugins.push(lovableBuildErrorDiagnostics());
|
|
505
|
+
}
|
|
376
506
|
const { tanstackStart } = await import("@tanstack/react-start/plugin/vite");
|
|
377
507
|
const tanstackStartDefaults = {
|
|
378
508
|
importProtection: {
|
package/dist/index.js
CHANGED
|
@@ -141,6 +141,133 @@ 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
|
+
}
|
|
144
271
|
function devSsrErrorLogger() {
|
|
145
272
|
let lastCapture;
|
|
146
273
|
const CAPTURE_TTL_MS = 5e3;
|
|
@@ -339,6 +466,9 @@ function defineConfig(configOrOptions = {}) {
|
|
|
339
466
|
if (options.ssrErrorLogger !== false) {
|
|
340
467
|
internalPlugins.push(devSsrErrorLogger());
|
|
341
468
|
}
|
|
469
|
+
if (command === "build" && isSandbox) {
|
|
470
|
+
internalPlugins.push(lovableBuildErrorDiagnostics());
|
|
471
|
+
}
|
|
342
472
|
const { tanstackStart } = await import("@tanstack/react-start/plugin/vite");
|
|
343
473
|
const tanstackStartDefaults = {
|
|
344
474
|
importProtection: {
|