@harlan-zw/nuxt-cloudflare 0.0.2 → 0.0.4

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/README.md CHANGED
@@ -13,6 +13,7 @@ The module extracts production patterns already proven in Nuxt SEO and gscdump.
13
13
  - `workers_dev` disabled when a route proves the Worker remains reachable; workers without routes must choose explicitly
14
14
  - Version metadata binding at `CF_VERSION_METADATA`
15
15
  - Workers Caching explicitly disabled by default; opt-in requires a version-sharing decision
16
+ - Smart Placement enabled by default; explicit region, host, or hostname placement is preserved
16
17
  - Source-map upload when the Nitro build emits maps; explicit `false` is preserved
17
18
  - Module-wide `secrets.required` names copied to each environment; source root secrets remain scoped to the root
18
19
  - Version metadata is skipped when `CF_VERSION_METADATA` already names another binding
@@ -57,7 +58,9 @@ export default defineNuxtConfig({
57
58
 
58
59
  Cloudflare KV requires TTLs of at least 60 seconds.
59
60
 
60
- Workers Caching is separate from Nitro's KV-backed cache. Enabling it lets Cloudflare serve responses without invoking the Worker. Keep `crossVersion: false` for deploy isolation; choose `true` only when stale responses across deployments are acceptable and a purge path exists. An authored `nitro.cloudflare.wrangler.cache` block is preserved unless `nuxtCloudflare.workersCache` is set.
61
+ Workers Caching is separate from Nitro's KV-backed cache. Enabling it lets Cloudflare serve responses without invoking the Worker. Keep `crossVersion: false` for deploy isolation; choose `true` only when stale responses across deployments are acceptable and a purge path exists. An authored `nitro.cloudflare.wrangler.cache` block is preserved unless `nuxtCloudflare.workersCache` is set; omitted `cross_version_cache` is normalized to `false`.
62
+
63
+ Smart Placement moves fetch handlers only when Cloudflare measures a faster location near upstream services. Assets-first delivery remains close to the user. Queue handlers, RPC methods, and named entrypoints are unaffected. An authored region, host, or hostname placement overrides the smart default.
61
64
 
62
65
  ## Doctor
63
66
 
@@ -177,7 +180,7 @@ The writer uses exclusive creation and mode 0600. It removes partial files after
177
180
 
178
181
  ## Deliberate boundaries
179
182
 
180
- The module does not choose Worker names, routes, domains, resource IDs, placement, CPU limits, queue jobs, R2 deletion policy, or deployment promotion. `@harlan-zw/nuxt-cf-jobs` continues to own queues, job durability, recovery, and outbox behavior.
183
+ The module does not choose Worker names, routes, domains, resource IDs, CPU limits, queue jobs, R2 deletion policy, or deployment promotion. `@harlan-zw/nuxt-cf-jobs` continues to own queues, job durability, recovery, and outbox behavior.
181
184
 
182
185
  Next high-value extractions from Nuxt SEO and gscdump:
183
186
 
@@ -187,7 +187,7 @@ const doctor = defineCommand({
187
187
  const main = defineCommand({
188
188
  meta: {
189
189
  name: "nuxt-cloudflare",
190
- version: "0.0.2",
190
+ version: "0.0.4",
191
191
  description: "Cloudflare deployment defaults and diagnostics for Nuxt"
192
192
  },
193
193
  subCommands: { doctor }
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=4.5.0"
6
6
  },
7
- "version": "0.0.2",
7
+ "version": "0.0.4",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.3",
10
10
  "unbuild": "3.6.1"
@@ -7,6 +7,27 @@ interface WranglerWorkersCacheInput {
7
7
  enabled: boolean;
8
8
  cross_version_cache?: boolean;
9
9
  }
10
+ type WranglerPlacementInput = {
11
+ mode: 'smart';
12
+ host?: never;
13
+ hostname?: never;
14
+ region?: never;
15
+ } | {
16
+ host: string;
17
+ hostname?: never;
18
+ mode?: never;
19
+ region?: never;
20
+ } | {
21
+ hostname: string;
22
+ host?: never;
23
+ mode?: never;
24
+ region?: never;
25
+ } | {
26
+ region: string;
27
+ host?: never;
28
+ hostname?: never;
29
+ mode?: never;
30
+ };
10
31
  type WorkersCachePolicy = {
11
32
  _tag: 'disabled';
12
33
  } | {
@@ -34,6 +55,7 @@ interface WranglerConfigInput extends Record<string, unknown> {
34
55
  env?: Record<string, WranglerConfigInput>;
35
56
  keep_vars?: boolean;
36
57
  observability?: WranglerObservabilityInput;
58
+ placement?: WranglerPlacementInput;
37
59
  preview_urls?: boolean;
38
60
  queues?: {
39
61
  consumers?: Array<Record<string, unknown>>;
@@ -94,4 +116,4 @@ declare function formatWranglerDiagnostics(diagnostics: readonly WranglerDiagnos
94
116
  declare function readWranglerJsonFile(path: string): Promise<WranglerJsonFileResult>;
95
117
 
96
118
  export { WRANGLER_DIAGNOSTIC_CODES, applyCloudflareDefaults, diagnoseWranglerConfig, formatWranglerDiagnostics, readWranglerJsonFile };
97
- export type { CloudflareDefaultOptions, WorkersCachePolicy, WranglerAssetsInput, WranglerConfigInput, WranglerDiagnostic, WranglerDiagnosticCode, WranglerDiagnosticOptions, WranglerJsonFileResult, WranglerObservabilityInput, WranglerWorkersCacheInput };
119
+ export type { CloudflareDefaultOptions, WorkersCachePolicy, WranglerAssetsInput, WranglerConfigInput, WranglerDiagnostic, WranglerDiagnosticCode, WranglerDiagnosticOptions, WranglerJsonFileResult, WranglerObservabilityInput, WranglerPlacementInput, WranglerWorkersCacheInput };
package/dist/wrangler.mjs CHANGED
@@ -60,6 +60,11 @@ function resolveWorkersCachePolicy(policy) {
60
60
  return { enabled: false, cross_version_cache: false };
61
61
  return { enabled: true, cross_version_cache: policy.crossVersion };
62
62
  }
63
+ function resolveAuthoredWorkersCache(cache) {
64
+ if (!cache)
65
+ return resolveWorkersCachePolicy({ _tag: "disabled" });
66
+ return { ...cache, cross_version_cache: cache.cross_version_cache ?? false };
67
+ }
63
68
  const WRANGLER_BINDING_CATEGORIES = [
64
69
  "data_blobs",
65
70
  "durable_objects",
@@ -139,7 +144,7 @@ function applyCloudflareDefaults(config, options = {}) {
139
144
  function applyEnvironmentDefaults(config, options, inherited = {}) {
140
145
  const compatibilityDate = config.compatibility_date ?? inherited.compatibility_date ?? options.compatibilityDate;
141
146
  const compatibilityFlags = unique([...config.compatibility_flags ?? inherited.compatibility_flags ?? [], "nodejs_compat"]);
142
- const cache = options.workersCache ? resolveWorkersCachePolicy(options.workersCache) : config.cache ?? inherited.cache ?? resolveWorkersCachePolicy({ _tag: "disabled" });
147
+ const cache = options.workersCache ? resolveWorkersCachePolicy(options.workersCache) : resolveAuthoredWorkersCache(config.cache ?? inherited.cache);
143
148
  const requiredSecrets = unique([...config.secrets?.required ?? [], ...options.requiredSecrets ?? []]);
144
149
  const logs = config.observability?.logs;
145
150
  const inheritedLogs = inherited.observability?.logs;
@@ -147,6 +152,7 @@ function applyEnvironmentDefaults(config, options, inherited = {}) {
147
152
  const inheritedTraces = inherited.observability?.traces;
148
153
  const uploadSourceMaps = config.upload_source_maps ?? inherited.upload_source_maps ?? options.uploadSourceMaps ?? true;
149
154
  const previewUrls = config.preview_urls ?? inherited.preview_urls ?? false;
155
+ const placement = config.placement ?? inherited.placement ?? { mode: "smart" };
150
156
  const workersDev = config.workers_dev ?? inherited.workers_dev ?? (config.route !== void 0 || (config.routes?.length ?? 0) > 0 ? false : void 0);
151
157
  const versionMetadataBinding = options.versionMetadataBinding ?? "CF_VERSION_METADATA";
152
158
  const localBindingNames = collectBindingNames(config);
@@ -174,6 +180,7 @@ function applyEnvironmentDefaults(config, options, inherited = {}) {
174
180
  head_sampling_rate: traces?.head_sampling_rate ?? inheritedTraces?.head_sampling_rate ?? options.tracesSampleRate ?? 0.01
175
181
  }
176
182
  },
183
+ placement,
177
184
  ...requiredSecrets.length > 0 ? { secrets: { ...config.secrets, required: requiredSecrets } } : {},
178
185
  upload_source_maps: uploadSourceMaps,
179
186
  ...versionMetadata ? { version_metadata: versionMetadata } : {},
@@ -512,6 +519,7 @@ function resolveEnvironmentPolicy(root, environment) {
512
519
  exports: environment.exports ?? root.exports,
513
520
  migrations: environment.migrations ?? root.migrations,
514
521
  observability: mergeObservability(root.observability, environment.observability),
522
+ placement: environment.placement ?? root.placement,
515
523
  preview_urls: environment.preview_urls ?? root.preview_urls,
516
524
  upload_source_maps: environment.upload_source_maps ?? root.upload_source_maps,
517
525
  workers_dev: environment.workers_dev ?? root.workers_dev
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@harlan-zw/nuxt-cloudflare",
3
3
  "type": "module",
4
- "version": "0.0.2",
4
+ "version": "0.0.4",
5
5
  "description": "Opinionated Cloudflare deployment defaults and diagnostics for Nuxt.",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",