Skip to content

feat: support wrangler.json and wrangler.jsonc#53

Merged
pi0 merged 3 commits intonitrojs:mainfrom
franklin-tina:main
Mar 6, 2025
Merged

feat: support wrangler.json and wrangler.jsonc#53
pi0 merged 3 commits intonitrojs:mainfrom
franklin-tina:main

Conversation

@franklin-tina
Copy link
Contributor

@franklin-tina franklin-tina commented Jan 8, 2025

  • Add support for the new experimental wrangler.json and wrangler.jsonc formats
  • Update wrangler to version 3.100.0

I tested this locally by:

  1. deleting the original wrangler.toml file
  2. creating a wrangler.json or wrangler.jsonc file with the following content:
{
  "compatibility_date": "2022-07-12",
  "kv_namespaces": [
    {
      "binding": "KV",
      "id": "<KV_ID>"
    },
    {
      "binding": "KV2", // <--- I added this.
      "id": "<KV2_ID>"
    }
  ],
  "r2_buckets": [
    {
      "binding": "BLOB",
      "bucket_name": "default"
    }
  ]
}

after running the dev:nitro command, opening the local dev server, I was able to read the values from the new config:

Keys of cloudflare: request, env, context

Keys of cloudflare.env: KV, KV2, BLOB

Colo: YXE

typeof cloudflare.context.waitUntil: function

Before creating this PR, I confirmed the new wrangler config format works by manually setting the configPath value to wrangler.jsonc (or wrangler.json) in my nuxt.config.ts file:

export default defineNuxtConfig({
  // stuff...
  nitro: {
    preset: "cloudflare-module",
    cloudflareDev: {
      configPath: "wrangler.jsonc",
    }
  },
})
Operating System: Darwin
Node Version:     v22.9.0
Nuxt Version:     3.15.1
CLI Version:      3.18.2
Nitro Version:    2.10.4
Package Manager:  bun@1.1.42
Builder:          -
User Config:      `compatibilityDate`, `devtools`, `future`, `modules`, `nitro`, vite`
Runtime Modules:  nitro-cloudflare-dev@0.2.1,
Build Modules:    -

fix: support multiple config file formats for Cloudflare
@franklin-tina franklin-tina changed the title feat: Add support for new the experimental wrangler config file formats feat: Add support for the new experimental wrangler config file formats Jan 8, 2025
@franklin-tina franklin-tina marked this pull request as ready for review January 8, 2025 07:45
@pi0 pi0 changed the title feat: Add support for the new experimental wrangler config file formats feat: support wrangler.json{,c} Jan 8, 2025
@pi0 pi0 changed the title feat: support wrangler.json{,c} feat: support wrangler.json and wrangler.jsonc Mar 6, 2025
@pi0 pi0 merged commit e2ec496 into nitrojs:main Mar 6, 2025
2 checks passed
@pi0
Copy link
Member

pi0 commented Mar 6, 2025

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants