@lovable.dev/vite-tanstack-config 1.4.1 → 1.4.3

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
@@ -130,94 +130,6 @@ function applyWatchDebounceDefaults(config) {
130
130
  }
131
131
  });
132
132
  }
133
- function devClientErrorLogger() {
134
- const VIRTUAL_ID = "virtual:dev-client-error-handler";
135
- const RESOLVED_ID = "\0" + VIRTUAL_ID;
136
- return {
137
- name: "dev-client-error-logger",
138
- apply: "serve",
139
- enforce: "pre",
140
- resolveId(id) {
141
- if (id === VIRTUAL_ID)
142
- return RESOLVED_ID;
143
- return void 0;
144
- },
145
- load(id) {
146
- if (id !== RESOLVED_ID)
147
- return void 0;
148
- return [
149
- "if (typeof window !== 'undefined' && import.meta.hot) {",
150
- " const send = (d) => { try { import.meta.hot.send('client-runtime-error', d) } catch {} };",
151
- " window.addEventListener('error', (e) => {",
152
- " send({ type: 'runtime-error', message: e.message, stack: e.error?.stack, filename: e.filename, lineno: e.lineno, colno: e.colno });",
153
- " });",
154
- " window.addEventListener('unhandledrejection', (e) => {",
155
- " const err = e.reason;",
156
- " send({ type: 'unhandled-rejection', message: err?.message || String(err), stack: err?.stack });",
157
- " });",
158
- "}"
159
- ].join("\n");
160
- },
161
- configureServer(server) {
162
- const origConsoleError = console.error;
163
- let forwarding = false;
164
- console.error = (...args) => {
165
- origConsoleError.apply(console, args);
166
- if (forwarding)
167
- return;
168
- forwarding = true;
169
- try {
170
- const error = args[0];
171
- if (error instanceof Error) {
172
- server.ws.send({
173
- type: "custom",
174
- event: "client-runtime-error",
175
- data: {
176
- source: "ssr",
177
- type: "ssr-render-error",
178
- name: error.name,
179
- message: error.message,
180
- stack: error.stack
181
- }
182
- });
183
- }
184
- } finally {
185
- forwarding = false;
186
- }
187
- };
188
- server.ws.on("client-runtime-error", (data) => {
189
- const { type, message, stack, filename, lineno, colno } = data;
190
- const label = type === "unhandled-rejection" ? "Unhandled Rejection" : "Runtime Error";
191
- let loc = "";
192
- if (filename) {
193
- loc = ` at ${filename}`;
194
- if (lineno != null)
195
- loc += `:${lineno}`;
196
- if (colno != null)
197
- loc += `:${colno}`;
198
- }
199
- server.config.logger.error(`
200
- [client] ${label}: ${message}${loc}`);
201
- if (stack) {
202
- server.config.logger.error(stack);
203
- }
204
- server.ws.send({
205
- type: "custom",
206
- event: "client-runtime-error",
207
- data
208
- });
209
- });
210
- },
211
- transform(code, id) {
212
- const normalizedId = id.replace(/\\/g, "/");
213
- if (normalizedId.includes("routes/__root")) {
214
- return `import "${VIRTUAL_ID}";
215
- ${code}`;
216
- }
217
- return void 0;
218
- }
219
- };
220
- }
221
133
  function devServerFnErrorLogger() {
222
134
  const HMR_SEND_KEY = "__TANSTACK_SERVER_FN_HMR_SEND__";
223
135
  return {
@@ -275,17 +187,15 @@ function defineConfig(configOrOptions = {}) {
275
187
  } else if (configOrOptions instanceof Promise) {
276
188
  options = { vite: await configOrOptions };
277
189
  } else {
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;
279
- options = hasLovableKey ? configOrOptions : { vite: configOrOptions };
190
+ const optionObject = configOrOptions && typeof configOrOptions === "object" ? configOrOptions : {};
191
+ const hasLovableKey = "vite" in optionObject || "serverFnErrorLogger" in optionObject || "cloudflare" in optionObject || "tanstackStart" in optionObject || "react" in optionObject || "envDefine" in optionObject || "hmrGate" in optionObject;
192
+ options = hasLovableKey ? optionObject : { vite: optionObject };
280
193
  }
281
194
  const internalPlugins = [];
282
195
  const tailwindcss = (await import("@tailwindcss/vite")).default;
283
196
  internalPlugins.push(tailwindcss());
284
197
  const tsConfigPaths = (await import("vite-tsconfig-paths")).default;
285
198
  internalPlugins.push(tsConfigPaths({ projects: ["./tsconfig.json"] }));
286
- if (options.clientErrorLogger !== false) {
287
- internalPlugins.push(devClientErrorLogger());
288
- }
289
199
  if (options.serverFnErrorLogger !== false) {
290
200
  internalPlugins.push(devServerFnErrorLogger());
291
201
  }
package/dist/index.d.cts CHANGED
@@ -1,10 +1,8 @@
1
1
  import { PluginOption, UserConfig, ConfigEnv, UserConfigFnObject, UserConfigFnPromise, UserConfigFn } from 'vite';
2
- import { HmrGateOptions } from '@lovable.dev/vite-plugin-hmr-gate';
3
2
 
4
3
  interface LovableViteTanstackOptions {
5
4
  plugins?: PluginOption[];
6
5
  vite?: UserConfig;
7
- clientErrorLogger?: boolean;
8
6
  serverFnErrorLogger?: boolean;
9
7
  cloudflare?: Record<string, unknown> | false;
10
8
  /** Options forwarded to tanstackStart(). */
@@ -18,7 +16,7 @@ interface LovableViteTanstackOptions {
18
16
  * Enabled by default in sandbox mode. Set to false to disable, or pass options
19
17
  * to customise behaviour. Set to true or an options object to enable outside sandbox.
20
18
  */
21
- hmrGate?: boolean | HmrGateOptions;
19
+ hmrGate?: boolean | Record<string, unknown>;
22
20
  }
23
21
  declare function defineConfig(config: UserConfig): (env: ConfigEnv) => Promise<UserConfig>;
24
22
  declare function defineConfig(config: Promise<UserConfig>): (env: ConfigEnv) => Promise<UserConfig>;
package/dist/index.d.ts CHANGED
@@ -1,10 +1,8 @@
1
1
  import { PluginOption, UserConfig, ConfigEnv, UserConfigFnObject, UserConfigFnPromise, UserConfigFn } from 'vite';
2
- import { HmrGateOptions } from '@lovable.dev/vite-plugin-hmr-gate';
3
2
 
4
3
  interface LovableViteTanstackOptions {
5
4
  plugins?: PluginOption[];
6
5
  vite?: UserConfig;
7
- clientErrorLogger?: boolean;
8
6
  serverFnErrorLogger?: boolean;
9
7
  cloudflare?: Record<string, unknown> | false;
10
8
  /** Options forwarded to tanstackStart(). */
@@ -18,7 +16,7 @@ interface LovableViteTanstackOptions {
18
16
  * Enabled by default in sandbox mode. Set to false to disable, or pass options
19
17
  * to customise behaviour. Set to true or an options object to enable outside sandbox.
20
18
  */
21
- hmrGate?: boolean | HmrGateOptions;
19
+ hmrGate?: boolean | Record<string, unknown>;
22
20
  }
23
21
  declare function defineConfig(config: UserConfig): (env: ConfigEnv) => Promise<UserConfig>;
24
22
  declare function defineConfig(config: Promise<UserConfig>): (env: ConfigEnv) => Promise<UserConfig>;
package/dist/index.js CHANGED
@@ -96,94 +96,6 @@ function applyWatchDebounceDefaults(config) {
96
96
  }
97
97
  });
98
98
  }
99
- function devClientErrorLogger() {
100
- const VIRTUAL_ID = "virtual:dev-client-error-handler";
101
- const RESOLVED_ID = "\0" + VIRTUAL_ID;
102
- return {
103
- name: "dev-client-error-logger",
104
- apply: "serve",
105
- enforce: "pre",
106
- resolveId(id) {
107
- if (id === VIRTUAL_ID)
108
- return RESOLVED_ID;
109
- return void 0;
110
- },
111
- load(id) {
112
- if (id !== RESOLVED_ID)
113
- return void 0;
114
- return [
115
- "if (typeof window !== 'undefined' && import.meta.hot) {",
116
- " const send = (d) => { try { import.meta.hot.send('client-runtime-error', d) } catch {} };",
117
- " window.addEventListener('error', (e) => {",
118
- " send({ type: 'runtime-error', message: e.message, stack: e.error?.stack, filename: e.filename, lineno: e.lineno, colno: e.colno });",
119
- " });",
120
- " window.addEventListener('unhandledrejection', (e) => {",
121
- " const err = e.reason;",
122
- " send({ type: 'unhandled-rejection', message: err?.message || String(err), stack: err?.stack });",
123
- " });",
124
- "}"
125
- ].join("\n");
126
- },
127
- configureServer(server) {
128
- const origConsoleError = console.error;
129
- let forwarding = false;
130
- console.error = (...args) => {
131
- origConsoleError.apply(console, args);
132
- if (forwarding)
133
- return;
134
- forwarding = true;
135
- try {
136
- const error = args[0];
137
- if (error instanceof Error) {
138
- server.ws.send({
139
- type: "custom",
140
- event: "client-runtime-error",
141
- data: {
142
- source: "ssr",
143
- type: "ssr-render-error",
144
- name: error.name,
145
- message: error.message,
146
- stack: error.stack
147
- }
148
- });
149
- }
150
- } finally {
151
- forwarding = false;
152
- }
153
- };
154
- server.ws.on("client-runtime-error", (data) => {
155
- const { type, message, stack, filename, lineno, colno } = data;
156
- const label = type === "unhandled-rejection" ? "Unhandled Rejection" : "Runtime Error";
157
- let loc = "";
158
- if (filename) {
159
- loc = ` at ${filename}`;
160
- if (lineno != null)
161
- loc += `:${lineno}`;
162
- if (colno != null)
163
- loc += `:${colno}`;
164
- }
165
- server.config.logger.error(`
166
- [client] ${label}: ${message}${loc}`);
167
- if (stack) {
168
- server.config.logger.error(stack);
169
- }
170
- server.ws.send({
171
- type: "custom",
172
- event: "client-runtime-error",
173
- data
174
- });
175
- });
176
- },
177
- transform(code, id) {
178
- const normalizedId = id.replace(/\\/g, "/");
179
- if (normalizedId.includes("routes/__root")) {
180
- return `import "${VIRTUAL_ID}";
181
- ${code}`;
182
- }
183
- return void 0;
184
- }
185
- };
186
- }
187
99
  function devServerFnErrorLogger() {
188
100
  const HMR_SEND_KEY = "__TANSTACK_SERVER_FN_HMR_SEND__";
189
101
  return {
@@ -241,17 +153,15 @@ function defineConfig(configOrOptions = {}) {
241
153
  } else if (configOrOptions instanceof Promise) {
242
154
  options = { vite: await configOrOptions };
243
155
  } else {
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;
245
- options = hasLovableKey ? configOrOptions : { vite: configOrOptions };
156
+ const optionObject = configOrOptions && typeof configOrOptions === "object" ? configOrOptions : {};
157
+ const hasLovableKey = "vite" in optionObject || "serverFnErrorLogger" in optionObject || "cloudflare" in optionObject || "tanstackStart" in optionObject || "react" in optionObject || "envDefine" in optionObject || "hmrGate" in optionObject;
158
+ options = hasLovableKey ? optionObject : { vite: optionObject };
246
159
  }
247
160
  const internalPlugins = [];
248
161
  const tailwindcss = (await import("@tailwindcss/vite")).default;
249
162
  internalPlugins.push(tailwindcss());
250
163
  const tsConfigPaths = (await import("vite-tsconfig-paths")).default;
251
164
  internalPlugins.push(tsConfigPaths({ projects: ["./tsconfig.json"] }));
252
- if (options.clientErrorLogger !== false) {
253
- internalPlugins.push(devClientErrorLogger());
254
- }
255
165
  if (options.serverFnErrorLogger !== false) {
256
166
  internalPlugins.push(devServerFnErrorLogger());
257
167
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lovable.dev/vite-tanstack-config",
3
- "version": "1.4.1",
3
+ "version": "1.4.3",
4
4
  "description": "Vite config wrapper for Lovable TanStack Start projects",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",