@lovable.dev/vite-tanstack-config 2.3.2-rc.0 → 2.3.2
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 +23 -0
- package/dist/index.js +23 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -43,6 +43,25 @@ function isSandboxEnvironment() {
|
|
|
43
43
|
function logWarning(message) {
|
|
44
44
|
console.warn(`[@lovable.dev/vite-tanstack-config] ${message}`);
|
|
45
45
|
}
|
|
46
|
+
var NITRO_DEFAULT_PRESET_MIN = [3, 0, 260603];
|
|
47
|
+
async function nitroSupportsDefaultPreset() {
|
|
48
|
+
try {
|
|
49
|
+
const { createRequire } = await import("module");
|
|
50
|
+
const require2 = createRequire(`${process.cwd()}/package.json`);
|
|
51
|
+
const { version } = require2("nitro/package.json");
|
|
52
|
+
const match = typeof version === "string" ? /^(\d+)\.(\d+)\.(\d+)/.exec(version) : null;
|
|
53
|
+
if (!match)
|
|
54
|
+
return true;
|
|
55
|
+
const parts = [Number(match[1]), Number(match[2]), Number(match[3])];
|
|
56
|
+
for (let i = 0; i < 3; i++) {
|
|
57
|
+
if (parts[i] !== NITRO_DEFAULT_PRESET_MIN[i])
|
|
58
|
+
return parts[i] > NITRO_DEFAULT_PRESET_MIN[i];
|
|
59
|
+
}
|
|
60
|
+
return true;
|
|
61
|
+
} catch {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
46
65
|
function validateHeaders(config) {
|
|
47
66
|
const headers = config.server?.headers;
|
|
48
67
|
if (!headers)
|
|
@@ -386,6 +405,10 @@ function defineConfig(configOrOptions = {}) {
|
|
|
386
405
|
nitroOpts.preset = "cloudflare-module";
|
|
387
406
|
nitroOpts.output = { dir: "dist", serverDir: "dist/server", publicDir: "dist/client" };
|
|
388
407
|
nitroOpts.cloudflare = { nodeCompat: true, deployConfig: true, ...userNitroOpts.cloudflare };
|
|
408
|
+
} else if (!nitroOpts.preset && !await nitroSupportsDefaultPreset()) {
|
|
409
|
+
logWarning(
|
|
410
|
+
'The installed `nitro` predates the `defaultPreset` option (3.0.260603-beta), so the Cloudflare fallback is ignored and a zero-config build may target Node instead. Upgrade nitro to >=3.0.260603-beta, or set an explicit `nitro: { preset: "cloudflare-module" }`.'
|
|
411
|
+
);
|
|
389
412
|
}
|
|
390
413
|
internalPlugins.push(nitro(nitroOpts));
|
|
391
414
|
}
|
package/dist/index.js
CHANGED
|
@@ -9,6 +9,25 @@ function isSandboxEnvironment() {
|
|
|
9
9
|
function logWarning(message) {
|
|
10
10
|
console.warn(`[@lovable.dev/vite-tanstack-config] ${message}`);
|
|
11
11
|
}
|
|
12
|
+
var NITRO_DEFAULT_PRESET_MIN = [3, 0, 260603];
|
|
13
|
+
async function nitroSupportsDefaultPreset() {
|
|
14
|
+
try {
|
|
15
|
+
const { createRequire } = await import("module");
|
|
16
|
+
const require2 = createRequire(`${process.cwd()}/package.json`);
|
|
17
|
+
const { version } = require2("nitro/package.json");
|
|
18
|
+
const match = typeof version === "string" ? /^(\d+)\.(\d+)\.(\d+)/.exec(version) : null;
|
|
19
|
+
if (!match)
|
|
20
|
+
return true;
|
|
21
|
+
const parts = [Number(match[1]), Number(match[2]), Number(match[3])];
|
|
22
|
+
for (let i = 0; i < 3; i++) {
|
|
23
|
+
if (parts[i] !== NITRO_DEFAULT_PRESET_MIN[i])
|
|
24
|
+
return parts[i] > NITRO_DEFAULT_PRESET_MIN[i];
|
|
25
|
+
}
|
|
26
|
+
return true;
|
|
27
|
+
} catch {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
12
31
|
function validateHeaders(config) {
|
|
13
32
|
const headers = config.server?.headers;
|
|
14
33
|
if (!headers)
|
|
@@ -352,6 +371,10 @@ function defineConfig(configOrOptions = {}) {
|
|
|
352
371
|
nitroOpts.preset = "cloudflare-module";
|
|
353
372
|
nitroOpts.output = { dir: "dist", serverDir: "dist/server", publicDir: "dist/client" };
|
|
354
373
|
nitroOpts.cloudflare = { nodeCompat: true, deployConfig: true, ...userNitroOpts.cloudflare };
|
|
374
|
+
} else if (!nitroOpts.preset && !await nitroSupportsDefaultPreset()) {
|
|
375
|
+
logWarning(
|
|
376
|
+
'The installed `nitro` predates the `defaultPreset` option (3.0.260603-beta), so the Cloudflare fallback is ignored and a zero-config build may target Node instead. Upgrade nitro to >=3.0.260603-beta, or set an explicit `nitro: { preset: "cloudflare-module" }`.'
|
|
377
|
+
);
|
|
355
378
|
}
|
|
356
379
|
internalPlugins.push(nitro(nitroOpts));
|
|
357
380
|
}
|