@lovable.dev/vite-tanstack-config 1.2.0 → 1.4.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 CHANGED
@@ -113,6 +113,23 @@ function cleanServerConfig(config) {
113
113
  }
114
114
  return config;
115
115
  }
116
+ function applyWatchDebounceDefaults(config) {
117
+ const existingWatch = config.server?.watch ?? {};
118
+ const existingAwaitWriteFinish = existingWatch.awaitWriteFinish;
119
+ const hasAwaitWriteFinishObject = !!existingAwaitWriteFinish && typeof existingAwaitWriteFinish === "object" && !Array.isArray(existingAwaitWriteFinish);
120
+ return (0, import_vite.mergeConfig)(config, {
121
+ server: {
122
+ watch: {
123
+ ...existingWatch,
124
+ awaitWriteFinish: {
125
+ ...hasAwaitWriteFinishObject ? existingAwaitWriteFinish : {},
126
+ stabilityThreshold: 1e3,
127
+ pollInterval: 100
128
+ }
129
+ }
130
+ }
131
+ });
132
+ }
116
133
  function devClientErrorLogger() {
117
134
  const VIRTUAL_ID = "virtual:dev-client-error-handler";
118
135
  const RESOLVED_ID = "\0" + VIRTUAL_ID;
@@ -258,7 +275,7 @@ function defineConfig(configOrOptions = {}) {
258
275
  } else if (configOrOptions instanceof Promise) {
259
276
  options = { vite: await configOrOptions };
260
277
  } else {
261
- const hasLovableKey = "vite" in configOrOptions || "clientErrorLogger" in configOrOptions || "serverFnErrorLogger" in configOrOptions || "cloudflare" in configOrOptions || "tanstackStart" in configOrOptions || "react" in configOrOptions || "envDefine" in configOrOptions;
278
+ const hasLovableKey = "vite" in configOrOptions || "clientErrorLogger" in configOrOptions || "serverFnErrorLogger" in configOrOptions || "cloudflare" in configOrOptions || "tanstackStart" in configOrOptions || "react" in configOrOptions || "envDefine" in configOrOptions || "hmrGate" in configOrOptions;
262
279
  options = hasLovableKey ? configOrOptions : { vite: configOrOptions };
263
280
  }
264
281
  const internalPlugins = [];
@@ -286,6 +303,15 @@ function defineConfig(configOrOptions = {}) {
286
303
  internalPlugins.push(tanstackStart(options.tanstackStart));
287
304
  const viteReact = (await import("@vitejs/plugin-react")).default;
288
305
  internalPlugins.push(viteReact(options.react));
306
+ if (command === "serve") {
307
+ const hmrGateOpt = options.hmrGate;
308
+ const enableHmrGate = isSandbox ? hmrGateOpt !== false : !!hmrGateOpt;
309
+ if (enableHmrGate) {
310
+ const { hmrGatePlugin } = await import("@lovable.dev/vite-plugin-hmr-gate");
311
+ const hmrGateOptions = typeof hmrGateOpt === "object" ? hmrGateOpt : {};
312
+ internalPlugins.push(hmrGatePlugin(hmrGateOptions));
313
+ }
314
+ }
289
315
  if (command === "serve" && mode === "development") {
290
316
  internalPlugins.push((0, import_lovable_tagger.componentTagger)());
291
317
  }
@@ -326,7 +352,10 @@ function defineConfig(configOrOptions = {}) {
326
352
  } else {
327
353
  config = (0, import_vite.mergeConfig)({ server: { host: "::", port: 8080 } }, config);
328
354
  }
329
- return config;
355
+ if (isSandbox) {
356
+ return config;
357
+ }
358
+ return applyWatchDebounceDefaults(config);
330
359
  };
331
360
  }
332
361
  // Annotate the CommonJS export names for ESM import in node:
package/dist/index.d.cts CHANGED
@@ -1,3 +1,4 @@
1
+ import { HmrGateOptions } from '@lovable.dev/vite-plugin-hmr-gate';
1
2
  import { PluginOption, UserConfig, ConfigEnv, UserConfigFnObject, UserConfigFnPromise, UserConfigFn } from 'vite';
2
3
 
3
4
  interface LovableViteTanstackOptions {
@@ -12,6 +13,12 @@ interface LovableViteTanstackOptions {
12
13
  react?: Record<string, unknown>;
13
14
  /** Set to false to disable automatic VITE_* env define injection. Default: true. */
14
15
  envDefine?: boolean;
16
+ /**
17
+ * Options for the HMR gate plugin (@lovable.dev/vite-plugin-hmr-gate).
18
+ * Enabled by default in sandbox mode. Set to false to disable, or pass options
19
+ * to customise behaviour. Set to true or an options object to enable outside sandbox.
20
+ */
21
+ hmrGate?: boolean | HmrGateOptions;
15
22
  }
16
23
  declare function defineConfig(config: UserConfig): (env: ConfigEnv) => Promise<UserConfig>;
17
24
  declare function defineConfig(config: Promise<UserConfig>): (env: ConfigEnv) => Promise<UserConfig>;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { HmrGateOptions } from '@lovable.dev/vite-plugin-hmr-gate';
1
2
  import { PluginOption, UserConfig, ConfigEnv, UserConfigFnObject, UserConfigFnPromise, UserConfigFn } from 'vite';
2
3
 
3
4
  interface LovableViteTanstackOptions {
@@ -12,6 +13,12 @@ interface LovableViteTanstackOptions {
12
13
  react?: Record<string, unknown>;
13
14
  /** Set to false to disable automatic VITE_* env define injection. Default: true. */
14
15
  envDefine?: boolean;
16
+ /**
17
+ * Options for the HMR gate plugin (@lovable.dev/vite-plugin-hmr-gate).
18
+ * Enabled by default in sandbox mode. Set to false to disable, or pass options
19
+ * to customise behaviour. Set to true or an options object to enable outside sandbox.
20
+ */
21
+ hmrGate?: boolean | HmrGateOptions;
15
22
  }
16
23
  declare function defineConfig(config: UserConfig): (env: ConfigEnv) => Promise<UserConfig>;
17
24
  declare function defineConfig(config: Promise<UserConfig>): (env: ConfigEnv) => Promise<UserConfig>;
package/dist/index.js CHANGED
@@ -79,6 +79,23 @@ function cleanServerConfig(config) {
79
79
  }
80
80
  return config;
81
81
  }
82
+ function applyWatchDebounceDefaults(config) {
83
+ const existingWatch = config.server?.watch ?? {};
84
+ const existingAwaitWriteFinish = existingWatch.awaitWriteFinish;
85
+ const hasAwaitWriteFinishObject = !!existingAwaitWriteFinish && typeof existingAwaitWriteFinish === "object" && !Array.isArray(existingAwaitWriteFinish);
86
+ return mergeConfig(config, {
87
+ server: {
88
+ watch: {
89
+ ...existingWatch,
90
+ awaitWriteFinish: {
91
+ ...hasAwaitWriteFinishObject ? existingAwaitWriteFinish : {},
92
+ stabilityThreshold: 1e3,
93
+ pollInterval: 100
94
+ }
95
+ }
96
+ }
97
+ });
98
+ }
82
99
  function devClientErrorLogger() {
83
100
  const VIRTUAL_ID = "virtual:dev-client-error-handler";
84
101
  const RESOLVED_ID = "\0" + VIRTUAL_ID;
@@ -224,7 +241,7 @@ function defineConfig(configOrOptions = {}) {
224
241
  } else if (configOrOptions instanceof Promise) {
225
242
  options = { vite: await configOrOptions };
226
243
  } else {
227
- const hasLovableKey = "vite" in configOrOptions || "clientErrorLogger" in configOrOptions || "serverFnErrorLogger" in configOrOptions || "cloudflare" in configOrOptions || "tanstackStart" in configOrOptions || "react" in configOrOptions || "envDefine" in configOrOptions;
244
+ const hasLovableKey = "vite" in configOrOptions || "clientErrorLogger" in configOrOptions || "serverFnErrorLogger" in configOrOptions || "cloudflare" in configOrOptions || "tanstackStart" in configOrOptions || "react" in configOrOptions || "envDefine" in configOrOptions || "hmrGate" in configOrOptions;
228
245
  options = hasLovableKey ? configOrOptions : { vite: configOrOptions };
229
246
  }
230
247
  const internalPlugins = [];
@@ -252,6 +269,15 @@ function defineConfig(configOrOptions = {}) {
252
269
  internalPlugins.push(tanstackStart(options.tanstackStart));
253
270
  const viteReact = (await import("@vitejs/plugin-react")).default;
254
271
  internalPlugins.push(viteReact(options.react));
272
+ if (command === "serve") {
273
+ const hmrGateOpt = options.hmrGate;
274
+ const enableHmrGate = isSandbox ? hmrGateOpt !== false : !!hmrGateOpt;
275
+ if (enableHmrGate) {
276
+ const { hmrGatePlugin } = await import("@lovable.dev/vite-plugin-hmr-gate");
277
+ const hmrGateOptions = typeof hmrGateOpt === "object" ? hmrGateOpt : {};
278
+ internalPlugins.push(hmrGatePlugin(hmrGateOptions));
279
+ }
280
+ }
255
281
  if (command === "serve" && mode === "development") {
256
282
  internalPlugins.push(componentTagger());
257
283
  }
@@ -292,7 +318,10 @@ function defineConfig(configOrOptions = {}) {
292
318
  } else {
293
319
  config = mergeConfig({ server: { host: "::", port: 8080 } }, config);
294
320
  }
295
- return config;
321
+ if (isSandbox) {
322
+ return config;
323
+ }
324
+ return applyWatchDebounceDefaults(config);
296
325
  };
297
326
  }
298
327
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lovable.dev/vite-tanstack-config",
3
- "version": "1.2.0",
3
+ "version": "1.4.0",
4
4
  "description": "Vite config wrapper for Lovable TanStack Start projects",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -26,6 +26,7 @@
26
26
  ],
27
27
  "license": "MIT",
28
28
  "dependencies": {
29
+ "@lovable.dev/vite-plugin-hmr-gate": "^1.0.0",
29
30
  "lovable-tagger": "1.1.13"
30
31
  },
31
32
  "peerDependencies": {