@vinext/cloudflare 1.0.0-beta.0 → 1.0.0-beta.1
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/cache/kv-data-adapter.runtime.js +1 -1
- package/dist/deploy.js +30 -22
- package/package.json +4 -3
package/dist/deploy.js
CHANGED
|
@@ -14,8 +14,8 @@ import { parseArgs } from "node:util";
|
|
|
14
14
|
import { pathToFileURL } from "node:url";
|
|
15
15
|
import { runPrerender } from "vinext/internal/build/run-prerender";
|
|
16
16
|
import { loadDotenv } from "vinext/internal/config/dotenv";
|
|
17
|
-
import { loadNextConfig, resolveNextConfig } from "vinext/internal/config/next-config";
|
|
18
|
-
import {
|
|
17
|
+
import { findVinextNextConfigInPlugins, loadNextConfig, resolveNextConfig, resolveNextConfigInput } from "vinext/internal/config/next-config";
|
|
18
|
+
import { findVinextCacheConfigInPlugins, findVinextPrerenderConfigInPlugins, findVinextRouteRootConfigInPlugins, formatVinextPrerenderLabel, resolveVinextPrerenderDecision } from "vinext/internal/config/prerender";
|
|
19
19
|
import { detectProject, findInNodeModules, formatMissingCloudflarePluginError, getMissingDeps } from "vinext/internal/utils/project";
|
|
20
20
|
import { PHASE_PRODUCTION_BUILD } from "vinext/shims/constants";
|
|
21
21
|
//#region src/deploy.ts
|
|
@@ -164,6 +164,18 @@ async function loadProjectViteApi(root) {
|
|
|
164
164
|
}
|
|
165
165
|
return await (vitePath === "vite" ? import(vitePath) : import(pathToFileURL(vitePath).href));
|
|
166
166
|
}
|
|
167
|
+
async function loadDeployViteConfigMetadata(root) {
|
|
168
|
+
const plugins = (await (await loadProjectViteApi(root)).loadConfigFromFile({
|
|
169
|
+
command: "build",
|
|
170
|
+
mode: "production"
|
|
171
|
+
}, void 0, root))?.config.plugins;
|
|
172
|
+
return {
|
|
173
|
+
cacheConfig: viteConfigHasCacheAdapter(root) ? await findVinextCacheConfigInPlugins(plugins) : null,
|
|
174
|
+
nextConfig: await findVinextNextConfigInPlugins(plugins),
|
|
175
|
+
prerenderConfig: await findVinextPrerenderConfigInPlugins(plugins),
|
|
176
|
+
routeRootConfig: await findVinextRouteRootConfigInPlugins(plugins)
|
|
177
|
+
};
|
|
178
|
+
}
|
|
167
179
|
async function runBuild(info, env) {
|
|
168
180
|
console.log("\n Building for Cloudflare Workers...\n");
|
|
169
181
|
const { createBuilder } = await loadProjectViteApi(info.root);
|
|
@@ -171,10 +183,8 @@ async function runBuild(info, env) {
|
|
|
171
183
|
await (await createBuilder({ root: info.root })).buildApp();
|
|
172
184
|
});
|
|
173
185
|
}
|
|
174
|
-
async function populateKVCacheFromPrerenderedArtifacts(root,
|
|
175
|
-
|
|
176
|
-
const vite = await loadProjectViteApi(root);
|
|
177
|
-
const kvConfig = resolveKvDataAdapterConfig(await withCloudflareEnv(buildEnv, () => loadVinextCacheConfigFromViteConfig(vite, root)));
|
|
186
|
+
async function populateKVCacheFromPrerenderedArtifacts(root, wranglerEnv, cacheConfig) {
|
|
187
|
+
const kvConfig = resolveKvDataAdapterConfig(cacheConfig);
|
|
178
188
|
if (!kvConfig) return;
|
|
179
189
|
const { routeCount, pairs } = buildPrerenderKVPairs(path.join(root, "dist", "server"), {
|
|
180
190
|
appPrefix: kvConfig.appPrefix,
|
|
@@ -483,11 +493,13 @@ async function deploy(options) {
|
|
|
483
493
|
console.log("\n Dry run complete. No build or deploy performed.\n");
|
|
484
494
|
return;
|
|
485
495
|
}
|
|
486
|
-
const nextConfig = await resolveNextConfig(await loadNextConfig(info.root, PHASE_PRODUCTION_BUILD), info.root);
|
|
487
496
|
const buildEnv = deployEnv === "production" && !options.env ? void 0 : deployEnv;
|
|
488
|
-
const
|
|
489
|
-
|
|
490
|
-
|
|
497
|
+
const viteConfigMetadata = await withCloudflareEnv(buildEnv, () => loadDeployViteConfigMetadata(info.root));
|
|
498
|
+
const nextConfig = await withCloudflareEnv(buildEnv, async () => {
|
|
499
|
+
const inlineNextConfig = viteConfigMetadata.nextConfig;
|
|
500
|
+
return resolveNextConfig(inlineNextConfig ? await resolveNextConfigInput(inlineNextConfig, PHASE_PRODUCTION_BUILD) : await loadNextConfig(info.root, PHASE_PRODUCTION_BUILD), info.root);
|
|
501
|
+
});
|
|
502
|
+
const vinextPrerenderConfig = !options.prerenderAll && nextConfig.output !== "export" ? viteConfigMetadata.prerenderConfig : null;
|
|
491
503
|
const prerenderDecision = resolveVinextPrerenderDecision({
|
|
492
504
|
prerenderAllFlag: options.prerenderAll,
|
|
493
505
|
vinextPrerenderConfig,
|
|
@@ -496,16 +508,11 @@ async function deploy(options) {
|
|
|
496
508
|
const shouldEmitPrerenderPathManifest = options.warmCdnCache || !options.skipBuild && prerenderDecision;
|
|
497
509
|
if (!options.skipBuild) await runBuild(info, buildEnv);
|
|
498
510
|
else console.log("\n Skipping build (--skip-build)");
|
|
499
|
-
if (shouldEmitPrerenderPathManifest) {
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
root: info.root,
|
|
505
|
-
nextConfigOverride: nextConfig,
|
|
506
|
-
routeRootConfig
|
|
507
|
-
});
|
|
508
|
-
}
|
|
511
|
+
if (shouldEmitPrerenderPathManifest) await emitPrerenderPathManifest({
|
|
512
|
+
root: info.root,
|
|
513
|
+
nextConfig,
|
|
514
|
+
routeRootConfig: viteConfigMetadata.routeRootConfig
|
|
515
|
+
});
|
|
509
516
|
let ranPrerender = false;
|
|
510
517
|
if (prerenderDecision) {
|
|
511
518
|
console.log(`\n ${formatVinextPrerenderLabel(prerenderDecision)}`);
|
|
@@ -515,12 +522,13 @@ async function deploy(options) {
|
|
|
515
522
|
}
|
|
516
523
|
await runPrerender({
|
|
517
524
|
root: info.root,
|
|
518
|
-
concurrency: options.prerenderConcurrency
|
|
525
|
+
concurrency: options.prerenderConcurrency,
|
|
526
|
+
nextConfig
|
|
519
527
|
});
|
|
520
528
|
ranPrerender = true;
|
|
521
529
|
}
|
|
522
530
|
if (ranPrerender) try {
|
|
523
|
-
await populateKVCacheFromPrerenderedArtifacts(root,
|
|
531
|
+
await populateKVCacheFromPrerenderedArtifacts(root, deployEnv === "production" && !options.env ? void 0 : deployEnv, viteConfigMetadata.cacheConfig);
|
|
524
532
|
} catch (error) {
|
|
525
533
|
console.log(` KV cache: Skipping prerender upload (${formatUnknownError(error)}). Continuing with deploy.`);
|
|
526
534
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vinext/cloudflare",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.1",
|
|
4
4
|
"description": "Cloudflare adapters for vinext (KV data cache and Images-backed image optimization).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -52,8 +52,9 @@
|
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/node": "^25.9.2",
|
|
55
|
-
"vite
|
|
56
|
-
"
|
|
55
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@0.2.2",
|
|
56
|
+
"vite-plus": "0.2.2",
|
|
57
|
+
"vinext": "1.0.0-beta.1"
|
|
57
58
|
},
|
|
58
59
|
"peerDependencies": {
|
|
59
60
|
"vinext": ">=0.0.0"
|