@lovable.dev/vite-tanstack-config 2.18.0 → 2.19.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 +26 -3
- package/dist/index.js +26 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -152,7 +152,7 @@ function bundledDevCssUrlShim() {
|
|
|
152
152
|
//#endregion
|
|
153
153
|
//#region package.json
|
|
154
154
|
var name = "@lovable.dev/vite-tanstack-config";
|
|
155
|
-
var version = "2.
|
|
155
|
+
var version = "2.19.0";
|
|
156
156
|
//#endregion
|
|
157
157
|
//#region src/logging.ts
|
|
158
158
|
const PACKAGE_NAME = "@lovable.dev/vite-tanstack-config";
|
|
@@ -198,15 +198,17 @@ function normalizeBasePath(raw) {
|
|
|
198
198
|
return trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
|
|
199
199
|
}
|
|
200
200
|
function withoutBasePath(route, basePath) {
|
|
201
|
-
if (route === basePath) return "/";
|
|
202
201
|
if (basePath === "") return route;
|
|
203
|
-
|
|
202
|
+
if (route === basePath) return "/";
|
|
203
|
+
if (route.startsWith(`${basePath}/`)) return route.slice(basePath.length);
|
|
204
|
+
return route.startsWith(basePath) ? void 0 : route;
|
|
204
205
|
}
|
|
205
206
|
function documentEntryForPage(page, basePath = "") {
|
|
206
207
|
if (typeof page.prerender?.outputPath === "string") return void 0;
|
|
207
208
|
const pagePath = normalizeRoute(page.path);
|
|
208
209
|
if (pagePath === void 0) return void 0;
|
|
209
210
|
const inner = withoutBasePath(pagePath, basePath);
|
|
211
|
+
if (inner === void 0) return void 0;
|
|
210
212
|
const route = normalizeRoute(`${basePath}${inner}`);
|
|
211
213
|
if (route === void 0) return void 0;
|
|
212
214
|
const file = inner === "/" ? "index.html" : `${inner.slice(1)}/index.html`;
|
|
@@ -261,6 +263,11 @@ async function whichExist(paths, access) {
|
|
|
261
263
|
}
|
|
262
264
|
return exists;
|
|
263
265
|
}
|
|
266
|
+
/** How the error names the public dir, which vite lets a project point anywhere. */
|
|
267
|
+
function publicDirLabel(root, publicDir, nodePath) {
|
|
268
|
+
const relative = nodePath.relative(root, publicDir);
|
|
269
|
+
return relative !== "" && !relative.startsWith("..") ? relative.split(nodePath.sep).join("/") : publicDir;
|
|
270
|
+
}
|
|
264
271
|
function createDocumentSet(routerBasePath) {
|
|
265
272
|
const basePath = normalizeBasePath(routerBasePath);
|
|
266
273
|
const basePathServable = basePath === "" || normalizeRoute(basePath) === basePath;
|
|
@@ -268,6 +275,7 @@ function createDocumentSet(routerBasePath) {
|
|
|
268
275
|
const documents = /* @__PURE__ */ new Map();
|
|
269
276
|
let root = process.cwd();
|
|
270
277
|
let clientOutputDir = CLIENT_OUTPUT_DIR;
|
|
278
|
+
let publicDir = "";
|
|
271
279
|
const plugin = {
|
|
272
280
|
name: DOCUMENT_SET_PLUGIN_NAME,
|
|
273
281
|
apply: "build",
|
|
@@ -279,6 +287,7 @@ function createDocumentSet(routerBasePath) {
|
|
|
279
287
|
const ours = names.indexOf(DOCUMENT_SET_PLUGIN_NAME);
|
|
280
288
|
if (theirs !== -1 && ours !== -1 && ours < theirs) logWarning(`Prerendered routes will fall back to SSR: ${DOCUMENT_SET_PLUGIN_NAME} is registered before ${TANSTACK_POST_BUILD_PLUGIN}, so the document set is written before the prerender pass runs.`);
|
|
281
289
|
clientOutputDir = config.environments?.client?.build?.outDir ?? CLIENT_OUTPUT_DIR;
|
|
290
|
+
publicDir = (config.environments?.client?.build?.copyPublicDir ?? config.build?.copyPublicDir) !== false && typeof config.publicDir === "string" ? config.publicDir : "";
|
|
282
291
|
},
|
|
283
292
|
buildApp: {
|
|
284
293
|
order: "post",
|
|
@@ -290,6 +299,20 @@ function createDocumentSet(routerBasePath) {
|
|
|
290
299
|
logWarning(`Could not remove a previous build's document set: ${String(error)}`);
|
|
291
300
|
});
|
|
292
301
|
if (documents.size === 0) return;
|
|
302
|
+
const collisions = [];
|
|
303
|
+
if (publicDir !== "") {
|
|
304
|
+
const candidates = [...documents].map(([route, file]) => ({
|
|
305
|
+
route,
|
|
306
|
+
file
|
|
307
|
+
}));
|
|
308
|
+
const committed = await whichExist(candidates.map(({ file }) => nodePath.join(publicDir, file)), access);
|
|
309
|
+
for (const [index, candidate] of candidates.entries()) if (committed[index]) collisions.push(candidate);
|
|
310
|
+
}
|
|
311
|
+
if (collisions.length > 0) {
|
|
312
|
+
const label = publicDirLabel(root, publicDir, nodePath);
|
|
313
|
+
const pairs = collisions.sort(compareRoutes).map(({ route, file }) => ` ${route} overwrites ${label}/${file}`);
|
|
314
|
+
throw new Error(`[${PACKAGE_NAME}] Prerendering would overwrite ${collisions.length} committed file(s) under ${label}/:\n${pairs.join("\n")}\nEach route's prerendered HTML is written into the client build after vite copies ${label}/, so every committed file above is replaced by its rendered route and never ships.\nFix each line above in one of two ways: delete or rename the ${label}/ file, or stop prerendering the route (drop it from \`pages\` in vite.config, or return false for it from \`prerender.filter\`).`);
|
|
315
|
+
}
|
|
293
316
|
const clientDir = nodePath.resolve(root, clientOutputDir);
|
|
294
317
|
const entries = [...documents].map(([route, file]) => ({
|
|
295
318
|
route,
|
package/dist/index.js
CHANGED
|
@@ -128,7 +128,7 @@ function bundledDevCssUrlShim() {
|
|
|
128
128
|
//#endregion
|
|
129
129
|
//#region package.json
|
|
130
130
|
var name = "@lovable.dev/vite-tanstack-config";
|
|
131
|
-
var version = "2.
|
|
131
|
+
var version = "2.19.0";
|
|
132
132
|
//#endregion
|
|
133
133
|
//#region src/logging.ts
|
|
134
134
|
const PACKAGE_NAME = "@lovable.dev/vite-tanstack-config";
|
|
@@ -174,15 +174,17 @@ function normalizeBasePath(raw) {
|
|
|
174
174
|
return trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
|
|
175
175
|
}
|
|
176
176
|
function withoutBasePath(route, basePath) {
|
|
177
|
-
if (route === basePath) return "/";
|
|
178
177
|
if (basePath === "") return route;
|
|
179
|
-
|
|
178
|
+
if (route === basePath) return "/";
|
|
179
|
+
if (route.startsWith(`${basePath}/`)) return route.slice(basePath.length);
|
|
180
|
+
return route.startsWith(basePath) ? void 0 : route;
|
|
180
181
|
}
|
|
181
182
|
function documentEntryForPage(page, basePath = "") {
|
|
182
183
|
if (typeof page.prerender?.outputPath === "string") return void 0;
|
|
183
184
|
const pagePath = normalizeRoute(page.path);
|
|
184
185
|
if (pagePath === void 0) return void 0;
|
|
185
186
|
const inner = withoutBasePath(pagePath, basePath);
|
|
187
|
+
if (inner === void 0) return void 0;
|
|
186
188
|
const route = normalizeRoute(`${basePath}${inner}`);
|
|
187
189
|
if (route === void 0) return void 0;
|
|
188
190
|
const file = inner === "/" ? "index.html" : `${inner.slice(1)}/index.html`;
|
|
@@ -237,6 +239,11 @@ async function whichExist(paths, access) {
|
|
|
237
239
|
}
|
|
238
240
|
return exists;
|
|
239
241
|
}
|
|
242
|
+
/** How the error names the public dir, which vite lets a project point anywhere. */
|
|
243
|
+
function publicDirLabel(root, publicDir, nodePath) {
|
|
244
|
+
const relative = nodePath.relative(root, publicDir);
|
|
245
|
+
return relative !== "" && !relative.startsWith("..") ? relative.split(nodePath.sep).join("/") : publicDir;
|
|
246
|
+
}
|
|
240
247
|
function createDocumentSet(routerBasePath) {
|
|
241
248
|
const basePath = normalizeBasePath(routerBasePath);
|
|
242
249
|
const basePathServable = basePath === "" || normalizeRoute(basePath) === basePath;
|
|
@@ -244,6 +251,7 @@ function createDocumentSet(routerBasePath) {
|
|
|
244
251
|
const documents = /* @__PURE__ */ new Map();
|
|
245
252
|
let root = process.cwd();
|
|
246
253
|
let clientOutputDir = CLIENT_OUTPUT_DIR;
|
|
254
|
+
let publicDir = "";
|
|
247
255
|
const plugin = {
|
|
248
256
|
name: DOCUMENT_SET_PLUGIN_NAME,
|
|
249
257
|
apply: "build",
|
|
@@ -255,6 +263,7 @@ function createDocumentSet(routerBasePath) {
|
|
|
255
263
|
const ours = names.indexOf(DOCUMENT_SET_PLUGIN_NAME);
|
|
256
264
|
if (theirs !== -1 && ours !== -1 && ours < theirs) logWarning(`Prerendered routes will fall back to SSR: ${DOCUMENT_SET_PLUGIN_NAME} is registered before ${TANSTACK_POST_BUILD_PLUGIN}, so the document set is written before the prerender pass runs.`);
|
|
257
265
|
clientOutputDir = config.environments?.client?.build?.outDir ?? CLIENT_OUTPUT_DIR;
|
|
266
|
+
publicDir = (config.environments?.client?.build?.copyPublicDir ?? config.build?.copyPublicDir) !== false && typeof config.publicDir === "string" ? config.publicDir : "";
|
|
258
267
|
},
|
|
259
268
|
buildApp: {
|
|
260
269
|
order: "post",
|
|
@@ -266,6 +275,20 @@ function createDocumentSet(routerBasePath) {
|
|
|
266
275
|
logWarning(`Could not remove a previous build's document set: ${String(error)}`);
|
|
267
276
|
});
|
|
268
277
|
if (documents.size === 0) return;
|
|
278
|
+
const collisions = [];
|
|
279
|
+
if (publicDir !== "") {
|
|
280
|
+
const candidates = [...documents].map(([route, file]) => ({
|
|
281
|
+
route,
|
|
282
|
+
file
|
|
283
|
+
}));
|
|
284
|
+
const committed = await whichExist(candidates.map(({ file }) => nodePath.join(publicDir, file)), access);
|
|
285
|
+
for (const [index, candidate] of candidates.entries()) if (committed[index]) collisions.push(candidate);
|
|
286
|
+
}
|
|
287
|
+
if (collisions.length > 0) {
|
|
288
|
+
const label = publicDirLabel(root, publicDir, nodePath);
|
|
289
|
+
const pairs = collisions.sort(compareRoutes).map(({ route, file }) => ` ${route} overwrites ${label}/${file}`);
|
|
290
|
+
throw new Error(`[${PACKAGE_NAME}] Prerendering would overwrite ${collisions.length} committed file(s) under ${label}/:\n${pairs.join("\n")}\nEach route's prerendered HTML is written into the client build after vite copies ${label}/, so every committed file above is replaced by its rendered route and never ships.\nFix each line above in one of two ways: delete or rename the ${label}/ file, or stop prerendering the route (drop it from \`pages\` in vite.config, or return false for it from \`prerender.filter\`).`);
|
|
291
|
+
}
|
|
269
292
|
const clientDir = nodePath.resolve(root, clientOutputDir);
|
|
270
293
|
const entries = [...documents].map(([route, file]) => ({
|
|
271
294
|
route,
|