@lovable.dev/vite-tanstack-config 2.5.4-rc.1 → 2.6.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 CHANGED
@@ -176,9 +176,13 @@ function isBuildError(error) {
176
176
  return BUILD_ERROR_MESSAGE.test(message);
177
177
  }
178
178
  var BUILD_DIAGNOSTICS_PLUGIN_NAME = "lovable-build-error-diagnostics";
179
+ var MAX_DIAGNOSTIC_JSON_LENGTH = 6e3;
179
180
  var MAX_DIAGNOSTIC_STRING_LENGTH = 2e3;
180
181
  var MAX_DIAGNOSTIC_NESTED_ERRORS = 20;
181
182
  var MAX_DIAGNOSTIC_DEPTH = 4;
183
+ var COMPACT_DIAGNOSTIC_STRING_LENGTH = 300;
184
+ var COMPACT_DIAGNOSTIC_NESTED_ERRORS = 3;
185
+ var COMPACT_DIAGNOSTIC_DEPTH = 3;
182
186
  var DIAGNOSTIC_ERROR_FIELDS = [
183
187
  "name",
184
188
  "message",
@@ -190,10 +194,14 @@ var DIAGNOSTIC_ERROR_FIELDS = [
190
194
  "code",
191
195
  "loc",
192
196
  "frame",
197
+ "stack",
193
198
  "cause"
194
199
  ];
195
200
  function truncateDiagnosticString(value) {
196
- return value.length > MAX_DIAGNOSTIC_STRING_LENGTH ? `${value.slice(0, MAX_DIAGNOSTIC_STRING_LENGTH)}...[truncated]` : value;
201
+ return truncateDiagnosticStringTo(value, MAX_DIAGNOSTIC_STRING_LENGTH);
202
+ }
203
+ function truncateDiagnosticStringTo(value, maxLength) {
204
+ return value.length > maxLength ? `${value.slice(0, maxLength)}...[truncated]` : value;
197
205
  }
198
206
  function readDiagnosticProperty(value, key) {
199
207
  try {
@@ -273,10 +281,62 @@ function serializeDiagnosticValue(value, depth, seen) {
273
281
  return output;
274
282
  const ownProperties = serializeOwnDiagnosticProperties(record, depth, seen);
275
283
  return Object.keys(ownProperties).length > 0 ? ownProperties : describeDiagnosticObject(value);
284
+ } catch (error) {
285
+ return `[unreadable object: ${error instanceof Error ? error.message : String(error)}]`;
276
286
  } finally {
277
287
  seen.delete(value);
278
288
  }
279
289
  }
290
+ function compactDiagnosticValue(value, depth) {
291
+ if (value == null)
292
+ return value;
293
+ if (typeof value === "string")
294
+ return truncateDiagnosticStringTo(value, COMPACT_DIAGNOSTIC_STRING_LENGTH);
295
+ if (typeof value === "number" || typeof value === "boolean")
296
+ return value;
297
+ if (typeof value !== "object")
298
+ return describeDiagnosticPrimitive(value);
299
+ if (depth >= COMPACT_DIAGNOSTIC_DEPTH)
300
+ return "[max depth]";
301
+ try {
302
+ if (Array.isArray(value)) {
303
+ const items = value.slice(0, COMPACT_DIAGNOSTIC_NESTED_ERRORS).map((item) => compactDiagnosticValue(item, depth + 1));
304
+ if (value.length > COMPACT_DIAGNOSTIC_NESTED_ERRORS) {
305
+ items.push(`[${value.length - COMPACT_DIAGNOSTIC_NESTED_ERRORS} items truncated]`);
306
+ }
307
+ return items;
308
+ }
309
+ const record = value;
310
+ const output = {};
311
+ const keys = Object.keys(record);
312
+ for (const key of keys.slice(0, MAX_DIAGNOSTIC_NESTED_ERRORS)) {
313
+ const nested = readDiagnosticProperty(record, key);
314
+ if (nested == null || nested === "")
315
+ continue;
316
+ output[key] = compactDiagnosticValue(nested, depth + 1);
317
+ }
318
+ if (keys.length > MAX_DIAGNOSTIC_NESTED_ERRORS) {
319
+ output.properties_truncated = keys.length - MAX_DIAGNOSTIC_NESTED_ERRORS;
320
+ }
321
+ return output;
322
+ } catch (error) {
323
+ return `[unreadable object: ${error instanceof Error ? error.message : String(error)}]`;
324
+ }
325
+ }
326
+ function stringifyDiagnosticPayload(diagnostics) {
327
+ const full = JSON.stringify(diagnostics);
328
+ if (full && full.length <= MAX_DIAGNOSTIC_JSON_LENGTH)
329
+ return full;
330
+ const compact = compactDiagnosticValue(diagnostics, 0);
331
+ const compactPayload = compact != null && typeof compact === "object" && !Array.isArray(compact) ? { ...compact, diagnostics_truncated: true } : { diagnostics_truncated: true, value: compact };
332
+ const compactJson = JSON.stringify(compactPayload);
333
+ if (compactJson.length <= MAX_DIAGNOSTIC_JSON_LENGTH)
334
+ return compactJson;
335
+ return JSON.stringify({
336
+ diagnostics_truncated: true,
337
+ message: "Diagnostic payload exceeded output budget."
338
+ });
339
+ }
280
340
  function lovableBuildErrorDiagnostics() {
281
341
  return {
282
342
  name: BUILD_DIAGNOSTICS_PLUGIN_NAME,
@@ -284,21 +344,27 @@ function lovableBuildErrorDiagnostics() {
284
344
  buildEnd(error) {
285
345
  if (!error)
286
346
  return;
287
- const diagnostics = serializeDiagnosticValue(error, 0, /* @__PURE__ */ new WeakSet());
288
- const output = `
347
+ try {
348
+ const diagnostics = serializeDiagnosticValue(error, 0, /* @__PURE__ */ new WeakSet());
349
+ const output = `
289
350
  [lovable-build-error-diagnostics]
290
- ${JSON.stringify(diagnostics)}
351
+ ${stringifyDiagnosticPayload(diagnostics)}
291
352
  [/lovable-build-error-diagnostics]
292
353
  `;
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);
354
+ let written = false;
355
+ const write = () => {
356
+ if (written)
357
+ return;
358
+ written = true;
359
+ try {
360
+ process.stderr.write(output);
361
+ } catch {
362
+ }
363
+ };
364
+ setImmediate(write);
365
+ process.once("exit", write);
366
+ } catch {
367
+ }
302
368
  }
303
369
  };
304
370
  }
@@ -516,12 +582,7 @@ function defineConfig(configOrOptions = {}) {
516
582
  const tanstackStartOptions = (0, import_vite.mergeConfig)(tanstackStartDefaults, options.tanstackStart ?? {});
517
583
  internalPlugins.push(tanstackStart(tanstackStartOptions));
518
584
  const explicitNitro = options.nitro === true || typeof options.nitro === "object" && options.nitro !== null;
519
- const shouldRunNitro = options.nitro !== false && command === "build" && (explicitNitro || isSandbox);
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
- }
585
+ const shouldRunNitro = options.nitro !== false && command === "build";
525
586
  if (shouldRunNitro) {
526
587
  let nitroMod;
527
588
  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): auto — nitro runs only when a Lovable context
13
- * is detected (sandbox + prod-deploy build via `DEV_SERVER__PROJECT_PATH`
14
- * / `LOVABLE_SANDBOX`). Users who clone their project and self-deploy
15
- * on their own infra get a Vite-only build with no Cloudflare-specific
16
- * bundling.
17
- * - **`true`**: force-on, defaulting to the `cloudflare-module` preset via
18
- * Nitro's `defaultPreset` — zero-config target auto-detection
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): auto — nitro runs only when a Lovable context
13
- * is detected (sandbox + prod-deploy build via `DEV_SERVER__PROJECT_PATH`
14
- * / `LOVABLE_SANDBOX`). Users who clone their project and self-deploy
15
- * on their own infra get a Vite-only build with no Cloudflare-specific
16
- * bundling.
17
- * - **`true`**: force-on, defaulting to the `cloudflare-module` preset via
18
- * Nitro's `defaultPreset` — zero-config target auto-detection
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
@@ -142,9 +142,13 @@ function isBuildError(error) {
142
142
  return BUILD_ERROR_MESSAGE.test(message);
143
143
  }
144
144
  var BUILD_DIAGNOSTICS_PLUGIN_NAME = "lovable-build-error-diagnostics";
145
+ var MAX_DIAGNOSTIC_JSON_LENGTH = 6e3;
145
146
  var MAX_DIAGNOSTIC_STRING_LENGTH = 2e3;
146
147
  var MAX_DIAGNOSTIC_NESTED_ERRORS = 20;
147
148
  var MAX_DIAGNOSTIC_DEPTH = 4;
149
+ var COMPACT_DIAGNOSTIC_STRING_LENGTH = 300;
150
+ var COMPACT_DIAGNOSTIC_NESTED_ERRORS = 3;
151
+ var COMPACT_DIAGNOSTIC_DEPTH = 3;
148
152
  var DIAGNOSTIC_ERROR_FIELDS = [
149
153
  "name",
150
154
  "message",
@@ -156,10 +160,14 @@ var DIAGNOSTIC_ERROR_FIELDS = [
156
160
  "code",
157
161
  "loc",
158
162
  "frame",
163
+ "stack",
159
164
  "cause"
160
165
  ];
161
166
  function truncateDiagnosticString(value) {
162
- return value.length > MAX_DIAGNOSTIC_STRING_LENGTH ? `${value.slice(0, MAX_DIAGNOSTIC_STRING_LENGTH)}...[truncated]` : value;
167
+ return truncateDiagnosticStringTo(value, MAX_DIAGNOSTIC_STRING_LENGTH);
168
+ }
169
+ function truncateDiagnosticStringTo(value, maxLength) {
170
+ return value.length > maxLength ? `${value.slice(0, maxLength)}...[truncated]` : value;
163
171
  }
164
172
  function readDiagnosticProperty(value, key) {
165
173
  try {
@@ -239,10 +247,62 @@ function serializeDiagnosticValue(value, depth, seen) {
239
247
  return output;
240
248
  const ownProperties = serializeOwnDiagnosticProperties(record, depth, seen);
241
249
  return Object.keys(ownProperties).length > 0 ? ownProperties : describeDiagnosticObject(value);
250
+ } catch (error) {
251
+ return `[unreadable object: ${error instanceof Error ? error.message : String(error)}]`;
242
252
  } finally {
243
253
  seen.delete(value);
244
254
  }
245
255
  }
256
+ function compactDiagnosticValue(value, depth) {
257
+ if (value == null)
258
+ return value;
259
+ if (typeof value === "string")
260
+ return truncateDiagnosticStringTo(value, COMPACT_DIAGNOSTIC_STRING_LENGTH);
261
+ if (typeof value === "number" || typeof value === "boolean")
262
+ return value;
263
+ if (typeof value !== "object")
264
+ return describeDiagnosticPrimitive(value);
265
+ if (depth >= COMPACT_DIAGNOSTIC_DEPTH)
266
+ return "[max depth]";
267
+ try {
268
+ if (Array.isArray(value)) {
269
+ const items = value.slice(0, COMPACT_DIAGNOSTIC_NESTED_ERRORS).map((item) => compactDiagnosticValue(item, depth + 1));
270
+ if (value.length > COMPACT_DIAGNOSTIC_NESTED_ERRORS) {
271
+ items.push(`[${value.length - COMPACT_DIAGNOSTIC_NESTED_ERRORS} items truncated]`);
272
+ }
273
+ return items;
274
+ }
275
+ const record = value;
276
+ const output = {};
277
+ const keys = Object.keys(record);
278
+ for (const key of keys.slice(0, MAX_DIAGNOSTIC_NESTED_ERRORS)) {
279
+ const nested = readDiagnosticProperty(record, key);
280
+ if (nested == null || nested === "")
281
+ continue;
282
+ output[key] = compactDiagnosticValue(nested, depth + 1);
283
+ }
284
+ if (keys.length > MAX_DIAGNOSTIC_NESTED_ERRORS) {
285
+ output.properties_truncated = keys.length - MAX_DIAGNOSTIC_NESTED_ERRORS;
286
+ }
287
+ return output;
288
+ } catch (error) {
289
+ return `[unreadable object: ${error instanceof Error ? error.message : String(error)}]`;
290
+ }
291
+ }
292
+ function stringifyDiagnosticPayload(diagnostics) {
293
+ const full = JSON.stringify(diagnostics);
294
+ if (full && full.length <= MAX_DIAGNOSTIC_JSON_LENGTH)
295
+ return full;
296
+ const compact = compactDiagnosticValue(diagnostics, 0);
297
+ const compactPayload = compact != null && typeof compact === "object" && !Array.isArray(compact) ? { ...compact, diagnostics_truncated: true } : { diagnostics_truncated: true, value: compact };
298
+ const compactJson = JSON.stringify(compactPayload);
299
+ if (compactJson.length <= MAX_DIAGNOSTIC_JSON_LENGTH)
300
+ return compactJson;
301
+ return JSON.stringify({
302
+ diagnostics_truncated: true,
303
+ message: "Diagnostic payload exceeded output budget."
304
+ });
305
+ }
246
306
  function lovableBuildErrorDiagnostics() {
247
307
  return {
248
308
  name: BUILD_DIAGNOSTICS_PLUGIN_NAME,
@@ -250,21 +310,27 @@ function lovableBuildErrorDiagnostics() {
250
310
  buildEnd(error) {
251
311
  if (!error)
252
312
  return;
253
- const diagnostics = serializeDiagnosticValue(error, 0, /* @__PURE__ */ new WeakSet());
254
- const output = `
313
+ try {
314
+ const diagnostics = serializeDiagnosticValue(error, 0, /* @__PURE__ */ new WeakSet());
315
+ const output = `
255
316
  [lovable-build-error-diagnostics]
256
- ${JSON.stringify(diagnostics)}
317
+ ${stringifyDiagnosticPayload(diagnostics)}
257
318
  [/lovable-build-error-diagnostics]
258
319
  `;
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);
320
+ let written = false;
321
+ const write = () => {
322
+ if (written)
323
+ return;
324
+ written = true;
325
+ try {
326
+ process.stderr.write(output);
327
+ } catch {
328
+ }
329
+ };
330
+ setImmediate(write);
331
+ process.once("exit", write);
332
+ } catch {
333
+ }
268
334
  }
269
335
  };
270
336
  }
@@ -482,12 +548,7 @@ function defineConfig(configOrOptions = {}) {
482
548
  const tanstackStartOptions = mergeConfig(tanstackStartDefaults, options.tanstackStart ?? {});
483
549
  internalPlugins.push(tanstackStart(tanstackStartOptions));
484
550
  const explicitNitro = options.nitro === true || typeof options.nitro === "object" && options.nitro !== null;
485
- const shouldRunNitro = options.nitro !== false && command === "build" && (explicitNitro || isSandbox);
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
- }
551
+ const shouldRunNitro = options.nitro !== false && command === "build";
491
552
  if (shouldRunNitro) {
492
553
  let nitroMod;
493
554
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lovable.dev/vite-tanstack-config",
3
- "version": "2.5.4-rc.1",
3
+ "version": "2.6.1",
4
4
  "description": "Vite config wrapper for Lovable TanStack Start projects",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",