@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.
@@ -324,7 +324,7 @@ var KVCacheHandler = class {
324
324
  return promise;
325
325
  }
326
326
  };
327
- const VALID_KINDS = new Set([
327
+ const VALID_KINDS = /* @__PURE__ */ new Set([
328
328
  "FETCH",
329
329
  "APP_PAGE",
330
330
  "PAGES",
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 { formatVinextPrerenderLabel, loadVinextCacheConfigFromViteConfig, loadVinextPrerenderConfigFromViteConfig, loadVinextRouteRootConfigFromViteConfig, resolveVinextPrerenderDecision } from "vinext/internal/config/prerender";
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, buildEnv, wranglerEnv) {
175
- if (!viteConfigHasCacheAdapter(root)) return;
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 vinextPrerenderConfig = !options.prerenderAll && nextConfig.output !== "export" ? await withCloudflareEnv(buildEnv, async () => {
489
- return loadVinextPrerenderConfigFromViteConfig(await loadProjectViteApi(info.root), info.root);
490
- }) : null;
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
- const routeRootConfig = await withCloudflareEnv(buildEnv, async () => {
501
- return loadVinextRouteRootConfigFromViteConfig(await loadProjectViteApi(info.root), info.root);
502
- });
503
- await emitPrerenderPathManifest({
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, buildEnv, deployEnv === "production" && !options.env ? void 0 : deployEnv);
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.0",
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-plus": "0.2.1",
56
- "vinext": "1.0.0-beta.0"
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"