@lovable.dev/vite-tanstack-config 1.5.0 → 1.6.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 +69 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +69 -1
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -130,6 +130,67 @@ function applyWatchDebounceDefaults(config) {
|
|
|
130
130
|
}
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
|
+
function devSsrErrorLogger() {
|
|
134
|
+
let lastCapture;
|
|
135
|
+
const CAPTURE_TTL_MS = 5e3;
|
|
136
|
+
const capture = (error) => {
|
|
137
|
+
lastCapture = { error, at: Date.now() };
|
|
138
|
+
};
|
|
139
|
+
const consumeCapture = () => {
|
|
140
|
+
if (!lastCapture)
|
|
141
|
+
return void 0;
|
|
142
|
+
if (Date.now() - lastCapture.at > CAPTURE_TTL_MS) {
|
|
143
|
+
lastCapture = void 0;
|
|
144
|
+
return void 0;
|
|
145
|
+
}
|
|
146
|
+
const { error } = lastCapture;
|
|
147
|
+
lastCapture = void 0;
|
|
148
|
+
return error;
|
|
149
|
+
};
|
|
150
|
+
return {
|
|
151
|
+
name: "dev-ssr-error-logger",
|
|
152
|
+
apply: "serve",
|
|
153
|
+
configureServer(server) {
|
|
154
|
+
const g = globalThis;
|
|
155
|
+
if (typeof g.addEventListener === "function") {
|
|
156
|
+
const addListener = g.addEventListener;
|
|
157
|
+
addListener("error", (e) => capture(e.error ?? e));
|
|
158
|
+
addListener("unhandledrejection", (e) => capture(e.reason));
|
|
159
|
+
}
|
|
160
|
+
const onUnhandledRejection = (reason) => capture(reason);
|
|
161
|
+
process.on("unhandledRejection", onUnhandledRejection);
|
|
162
|
+
server.httpServer?.once("close", () => {
|
|
163
|
+
process.off("unhandledRejection", onUnhandledRejection);
|
|
164
|
+
});
|
|
165
|
+
server.middlewares.use((_req, res, next) => {
|
|
166
|
+
const origEnd = res.end.bind(res);
|
|
167
|
+
res.end = (...args) => {
|
|
168
|
+
if (res.statusCode >= 500) {
|
|
169
|
+
const captured = consumeCapture();
|
|
170
|
+
let err;
|
|
171
|
+
if (captured instanceof Error) {
|
|
172
|
+
err = captured;
|
|
173
|
+
} else if (typeof captured === "string" && captured.length > 0) {
|
|
174
|
+
err = new Error(captured);
|
|
175
|
+
} else {
|
|
176
|
+
err = null;
|
|
177
|
+
}
|
|
178
|
+
try {
|
|
179
|
+
server.ws.send({
|
|
180
|
+
type: "custom",
|
|
181
|
+
event: "server-ssr-error",
|
|
182
|
+
data: err ? { name: err.name, message: err.message, stack: err.stack } : { name: "Error", message: "SSR rendering failed" }
|
|
183
|
+
});
|
|
184
|
+
} catch {
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return origEnd(...args);
|
|
188
|
+
};
|
|
189
|
+
next();
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
}
|
|
133
194
|
function devServerFnErrorLogger() {
|
|
134
195
|
const HMR_SEND_KEY = "__TANSTACK_SERVER_FN_HMR_SEND__";
|
|
135
196
|
return {
|
|
@@ -188,7 +249,7 @@ function defineConfig(configOrOptions = {}) {
|
|
|
188
249
|
options = { vite: await configOrOptions };
|
|
189
250
|
} else {
|
|
190
251
|
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;
|
|
252
|
+
const hasLovableKey = "vite" in optionObject || "serverFnErrorLogger" in optionObject || "ssrErrorLogger" in optionObject || "cloudflare" in optionObject || "tanstackStart" in optionObject || "react" in optionObject || "envDefine" in optionObject || "hmrGate" in optionObject;
|
|
192
253
|
options = hasLovableKey ? optionObject : { vite: optionObject };
|
|
193
254
|
}
|
|
194
255
|
const internalPlugins = [];
|
|
@@ -199,6 +260,9 @@ function defineConfig(configOrOptions = {}) {
|
|
|
199
260
|
if (options.serverFnErrorLogger !== false) {
|
|
200
261
|
internalPlugins.push(devServerFnErrorLogger());
|
|
201
262
|
}
|
|
263
|
+
if (options.ssrErrorLogger !== false) {
|
|
264
|
+
internalPlugins.push(devSsrErrorLogger());
|
|
265
|
+
}
|
|
202
266
|
if (options.cloudflare !== false && command === "build") {
|
|
203
267
|
try {
|
|
204
268
|
const { cloudflare } = await import("@cloudflare/vite-plugin");
|
|
@@ -232,6 +296,10 @@ function defineConfig(configOrOptions = {}) {
|
|
|
232
296
|
internalPlugins.push(hmrGatePlugin(hmrGateOptions));
|
|
233
297
|
}
|
|
234
298
|
}
|
|
299
|
+
if (command === "serve" && isSandbox) {
|
|
300
|
+
const { devServerBridgePlugin } = await import("@lovable.dev/vite-plugin-dev-server-bridge");
|
|
301
|
+
internalPlugins.push(devServerBridgePlugin());
|
|
302
|
+
}
|
|
235
303
|
if (command === "serve" && mode === "development") {
|
|
236
304
|
internalPlugins.push((0, import_lovable_tagger.componentTagger)());
|
|
237
305
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -4,6 +4,7 @@ interface LovableViteTanstackOptions {
|
|
|
4
4
|
plugins?: PluginOption[];
|
|
5
5
|
vite?: UserConfig;
|
|
6
6
|
serverFnErrorLogger?: boolean;
|
|
7
|
+
ssrErrorLogger?: boolean;
|
|
7
8
|
cloudflare?: Record<string, unknown> | false;
|
|
8
9
|
/** Options forwarded to tanstackStart(). */
|
|
9
10
|
tanstackStart?: Record<string, unknown>;
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ interface LovableViteTanstackOptions {
|
|
|
4
4
|
plugins?: PluginOption[];
|
|
5
5
|
vite?: UserConfig;
|
|
6
6
|
serverFnErrorLogger?: boolean;
|
|
7
|
+
ssrErrorLogger?: boolean;
|
|
7
8
|
cloudflare?: Record<string, unknown> | false;
|
|
8
9
|
/** Options forwarded to tanstackStart(). */
|
|
9
10
|
tanstackStart?: Record<string, unknown>;
|
package/dist/index.js
CHANGED
|
@@ -96,6 +96,67 @@ function applyWatchDebounceDefaults(config) {
|
|
|
96
96
|
}
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
|
+
function devSsrErrorLogger() {
|
|
100
|
+
let lastCapture;
|
|
101
|
+
const CAPTURE_TTL_MS = 5e3;
|
|
102
|
+
const capture = (error) => {
|
|
103
|
+
lastCapture = { error, at: Date.now() };
|
|
104
|
+
};
|
|
105
|
+
const consumeCapture = () => {
|
|
106
|
+
if (!lastCapture)
|
|
107
|
+
return void 0;
|
|
108
|
+
if (Date.now() - lastCapture.at > CAPTURE_TTL_MS) {
|
|
109
|
+
lastCapture = void 0;
|
|
110
|
+
return void 0;
|
|
111
|
+
}
|
|
112
|
+
const { error } = lastCapture;
|
|
113
|
+
lastCapture = void 0;
|
|
114
|
+
return error;
|
|
115
|
+
};
|
|
116
|
+
return {
|
|
117
|
+
name: "dev-ssr-error-logger",
|
|
118
|
+
apply: "serve",
|
|
119
|
+
configureServer(server) {
|
|
120
|
+
const g = globalThis;
|
|
121
|
+
if (typeof g.addEventListener === "function") {
|
|
122
|
+
const addListener = g.addEventListener;
|
|
123
|
+
addListener("error", (e) => capture(e.error ?? e));
|
|
124
|
+
addListener("unhandledrejection", (e) => capture(e.reason));
|
|
125
|
+
}
|
|
126
|
+
const onUnhandledRejection = (reason) => capture(reason);
|
|
127
|
+
process.on("unhandledRejection", onUnhandledRejection);
|
|
128
|
+
server.httpServer?.once("close", () => {
|
|
129
|
+
process.off("unhandledRejection", onUnhandledRejection);
|
|
130
|
+
});
|
|
131
|
+
server.middlewares.use((_req, res, next) => {
|
|
132
|
+
const origEnd = res.end.bind(res);
|
|
133
|
+
res.end = (...args) => {
|
|
134
|
+
if (res.statusCode >= 500) {
|
|
135
|
+
const captured = consumeCapture();
|
|
136
|
+
let err;
|
|
137
|
+
if (captured instanceof Error) {
|
|
138
|
+
err = captured;
|
|
139
|
+
} else if (typeof captured === "string" && captured.length > 0) {
|
|
140
|
+
err = new Error(captured);
|
|
141
|
+
} else {
|
|
142
|
+
err = null;
|
|
143
|
+
}
|
|
144
|
+
try {
|
|
145
|
+
server.ws.send({
|
|
146
|
+
type: "custom",
|
|
147
|
+
event: "server-ssr-error",
|
|
148
|
+
data: err ? { name: err.name, message: err.message, stack: err.stack } : { name: "Error", message: "SSR rendering failed" }
|
|
149
|
+
});
|
|
150
|
+
} catch {
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return origEnd(...args);
|
|
154
|
+
};
|
|
155
|
+
next();
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
}
|
|
99
160
|
function devServerFnErrorLogger() {
|
|
100
161
|
const HMR_SEND_KEY = "__TANSTACK_SERVER_FN_HMR_SEND__";
|
|
101
162
|
return {
|
|
@@ -154,7 +215,7 @@ function defineConfig(configOrOptions = {}) {
|
|
|
154
215
|
options = { vite: await configOrOptions };
|
|
155
216
|
} else {
|
|
156
217
|
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;
|
|
218
|
+
const hasLovableKey = "vite" in optionObject || "serverFnErrorLogger" in optionObject || "ssrErrorLogger" in optionObject || "cloudflare" in optionObject || "tanstackStart" in optionObject || "react" in optionObject || "envDefine" in optionObject || "hmrGate" in optionObject;
|
|
158
219
|
options = hasLovableKey ? optionObject : { vite: optionObject };
|
|
159
220
|
}
|
|
160
221
|
const internalPlugins = [];
|
|
@@ -165,6 +226,9 @@ function defineConfig(configOrOptions = {}) {
|
|
|
165
226
|
if (options.serverFnErrorLogger !== false) {
|
|
166
227
|
internalPlugins.push(devServerFnErrorLogger());
|
|
167
228
|
}
|
|
229
|
+
if (options.ssrErrorLogger !== false) {
|
|
230
|
+
internalPlugins.push(devSsrErrorLogger());
|
|
231
|
+
}
|
|
168
232
|
if (options.cloudflare !== false && command === "build") {
|
|
169
233
|
try {
|
|
170
234
|
const { cloudflare } = await import("@cloudflare/vite-plugin");
|
|
@@ -198,6 +262,10 @@ function defineConfig(configOrOptions = {}) {
|
|
|
198
262
|
internalPlugins.push(hmrGatePlugin(hmrGateOptions));
|
|
199
263
|
}
|
|
200
264
|
}
|
|
265
|
+
if (command === "serve" && isSandbox) {
|
|
266
|
+
const { devServerBridgePlugin } = await import("@lovable.dev/vite-plugin-dev-server-bridge");
|
|
267
|
+
internalPlugins.push(devServerBridgePlugin());
|
|
268
|
+
}
|
|
201
269
|
if (command === "serve" && mode === "development") {
|
|
202
270
|
internalPlugins.push(componentTagger());
|
|
203
271
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lovable.dev/vite-tanstack-config",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.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-dev-server-bridge": "^1.0.0",
|
|
29
30
|
"@lovable.dev/vite-plugin-hmr-gate": "^1.0.0",
|
|
30
31
|
"lovable-tagger": "1.2.0"
|
|
31
32
|
},
|