包详细信息

nitro-cloudflare-dev

pi051.5kMIT0.2.2

POC module to enable access to the Cloudflare runtime bindings in development server of Nitro and Nuxt

自述文件

Cloudflare Platform for Nitro and Nuxt

This proof of concept module enables access to the Cloudflare runtime platform in the development server of Nitro and Nuxt using the new getPlatformProxy API exposed by wrangler and miniflare

[!NOTE] Nitro plans to introduce a new method to allow native dev presets, meaning you can natively run miniflare as your development server without this module or a proxy in the future!

Usage

First, install nitro-cloudflare-dev and wrangler packages as a dev dependency: (unjs/nypm will automatically detect your package manager!)

npx nypm@latest add -D wrangler nitro-cloudflare-dev

For Nuxt update nuxt.config.ts:

export default defineNuxtConfig({
  modules: ["nitro-cloudflare-dev"],
});

For Nitro update nitro.config.ts:

import nitroCloudflareBindings from "nitro-cloudflare-dev";

export default defineNitroConfig({
  modules: [nitroCloudflareBindings],
});

Configuration and persistence

This module automatically finds the closest wrangler.toml file for configuration.

Data is persisted .wrangler/state/v3 directory. On first use of the module, it will be automatically added to the .gitignore file.

You can configure additional options using cloudflareDev: { } in nitro.config or nitro: { cloudflareDev: {} } in nuxt.config.

Available options

  • persistDir: Sets the persist dir (default .wrangler/state/v3).
  • configPath: Sets a custom path for wrangler.toml file.
  • silent: Hide initial banner.
  • environment: Sets specific environment (useful for multi-environment configurations)

Development

  • Clone this repository
  • Install the latest LTS version of Node.js
  • Enable Corepack using corepack enable
  • Install dependencies using pnpm install
  • Build in stub mode using pnpm build --stub
  • Run Nitro playground using pnpm dev:nitro or Nuxt playground using pnpm dev:nuxt

License

MIT

更新日志

Changelog

v0.2.2

compare changes

🚀 Enhancements

  • Support wrangler.json and wrangler.jsonc (#53)

🏡 Chore

❤️ Contributors

v0.2.1

compare changes

🩹 Fixes

  • wrangler: Only set environment if defined (#49)

🏡 Chore

❤️ Contributors

v0.2.0

compare changes

💅 Refactors

  • ⚠️ Remove shamefullyPatchR2Buckets option (#47)

🏡 Chore

⚠️ Breaking Changes

  • ⚠️ Remove shamefullyPatchR2Buckets option (#47)

❤️ Contributors

v0.1.6

compare changes

🩹 Fixes

  • Bind context (#35)

🏡 Chore

❤️ Contributors

v0.1.5

compare changes

🚀 Enhancements

  • Support environment config (#27)

🏡 Chore

❤️ Contributors

v0.1.4

compare changes

🩹 Fixes

  • r2-patch: Await for mutex to be exclusive (1b9db53)

❤️ Contributors

  • Pooya Parsa (@pi0)

v0.1.3

compare changes

🚀 Enhancements

  • Add shamefullyPatchR2Buckets (e15e190)

🏡 Chore

❤️ Contributors

  • Pooya Parsa (@pi0)

v0.1.2

compare changes

🚀 Enhancements

  • Add configPath and silent options (#12)

🏡 Chore

❤️ Contributors

v0.1.1

compare changes

🔥 Performance

  • Try eagerly initializing proxy (81113d6)

❤️ Contributors

  • Pooya Parsa (@pi0)

v0.1.0

compare changes

🚀 Enhancements

  • ⚠️ Use getPlatformProxy and provide more context fields (#6)
  • Support configurable persistDir (725fd42)
  • Log initialization time (be0deec)
  • Replicate nitro production behavior (36ad28e)

🩹 Fixes

  • Slash runtime path (#8)
  • Use H3EventContext (745a2d5)
  • Allow access to the context within request hook (cab495a)

💅 Refactors

📦 Build

  • Externalize wrangler types (e4092d4)

🌊 Types

🏡 Chore

⚠️ Breaking Changes

  • ⚠️ Use getPlatformProxy and provide more context fields (#6)

❤️ Contributors

v0.0.7

compare changes

🩹 Fixes

  • Make sure runtime/ is transpiled (77156bb)

💅 Refactors

  • Rename to nitro-cloudflare-dev (c389c42)

🏡 Chore

  • Update gitignore (4b03f4b)
  • release: V0.0.6 (95d6f24)
  • Use nypm for install (1a16886)
  • Update readme (remove mention of beta version of wrangler) (9b7a74e)
  • Bump wrangler devDependency (7f66c67)

❤️ Contributors

v0.0.6

compare changes

🩹 Fixes

  • Make sure runtime/ is transpiled (77156bb)

🏡 Chore

❤️ Contributors

  • Pooya Parsa (@pi0)

v0.0.5

compare changes

🏡 Chore

❤️ Contributors

  • Pooya Parsa (@pi0)

v0.0.4

compare changes

🩹 Fixes

  • Explicit import from #imports (dfcfb53)

💅 Refactors

  • Graceful error when cannot get bindings (762f747)
  • Compact message for added to .gitignore (67e1828)

❤️ Contributors

  • Pooya Parsa (@pi0)

v0.0.3

compare changes

📦 Build

❤️ Contributors

  • Pooya Parsa (@pi0)

v0.0.2

compare changes

🚀 Enhancements

  • Automatically add .wrangler/state/v3 to .gitignore (5bf2c5b)

🩹 Fixes

  • Handle when wrangler.toml is not found (0340c1d)

💅 Refactors

  • Default persist dir to .wrangler/state/v3 (88d91ff)

📦 Build

  • Run build before release (d3f32d2)

🏡 Chore

❤️ Contributors

  • Pooya Parsa (@pi0)

v0.0.1

🏡 Chore

❤️ Contributors

  • Pooya Parsa (@pi0)