npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

vite-plus-wrangler

v0.1.0

Published

Cloudflare Wrangler plugin and CLI for the Vite+ toolchain — task wiring, account guards, D1 migrations, and config discovery

Readme

vite-plus-wrangler ⚡☁️

Cloudflare Wrangler plugin and CLI for the Vite+ toolchain. Task wiring with caching, account guards, D1 migration checks, and monorepo-wide config discovery.

License: MIT Vite+ Node.js Version


Why

Wrangler is a great CLI and a poor build system. Every project ends up with its own hand-rolled dev/deploy/d1:migrate scripts, its own account-id handling, and no caching. This plugin moves all of that into vite.config.ts so it is declared once and shared.

  • 🎯 Task wiring — cf:dev, cf:deploy, cf:preview, cf:types as real vp run tasks with caching, inputs/outputs, and dependency ordering.
  • 🔒 Account guard — a deploy fails closed when the config's account_id and CLOUDFLARE_ACCOUNT_ID disagree, or when neither is set.
  • 🗃 D1 migrations — local/remote/status tasks plus prefix-ordering checks, because Wrangler applies migrations lexicographically.
  • 🔎 Config discovery — parses every wrangler.toml / .json / .jsonc in a monorepo, resolving [env.*] inheritance.
  • 🦀 Rust core — config parsing, discovery, and checks run in a single native binary; the Node layer is a thin wrapper.

Installation

vp add -D vite-plus-wrangler

Quick start

Single Worker

import { defineConfig } from "vite-plus";
import { wrangler, wranglerTasks } from "vite-plus-wrangler";

export default defineConfig({
  plugins: [wrangler()],
  run: {
    tasks: wranglerTasks({
      config: "wrangler.jsonc",
      d1: "my-app-db",
      port: 8787,
    }),
  },
});
vp run cf:dev
vp run cf:deploy

Monorepo

import { defineConfig } from "vite-plus";
import { wrangler, discoverWranglerTasks } from "vite-plus-wrangler";

export default defineConfig({
  plugins: [wrangler({ depth: 4 })],
  run: {
    tasks: discoverWranglerTasks(),
  },
});

Every discovered Worker gets namespaced tasks:

vp run api#cf:deploy
vp run webhooks#cf:dev

Account guard

The single most valuable thing here. Deploying to the wrong Cloudflare account is easy and expensive to undo.

| Config account_id | CLOUDFLARE_ACCOUNT_ID | Result | | ------------------- | ----------------------- | ----------------------- | | set | set, same | ✅ proceed | | set | set, different | ❌ refuse | | set | unset | ✅ proceed, config wins | | unset | set | ⚠️ proceed with warning | | unset | unset | ❌ refuse |

import { assertAccount } from "vite-plus-wrangler";

assertAccount("wrangler.toml", { env: "production" });

Or standalone:

vite-plus-wrangler account-check wrangler.toml --env production

An environment name that is not declared in the config is an error, not a fallback — --env producton fails loudly rather than quietly checking the default environment.

What the guard does not do: it compares two declared values, the config's account_id and CLOUDFLARE_ACCOUNT_ID. It does not contact Cloudflare, so it cannot tell you that CLOUDFLARE_API_TOKEN is scoped to a different account than the one those two agree on. It catches a stale env var from another project, not a mis-scoped token.


D1 migrations

Wrangler orders migrations lexicographically, so 10_x.sql sorts before 9_x.sql. The checker catches inconsistent prefix widths, duplicate prefixes, sequence gaps, and non-conforming filenames.

Both sequential (0001_) and timestamp (20240101120000_) prefixes are supported. Gap warnings apply only to sequential numbering, since timestamps are never contiguous.

migrations_dir is resolved relative to the wrangler config file, matching Wrangler's own behavior.

vite-plus-wrangler migrations migrations
import { assertMigrations } from "vite-plus-wrangler";

assertMigrations("migrations");

Generated tasks: d1:migrate:local, d1:migrate:remote, d1:migrate:status, d1:migrate:check.


CLI

vite-plus-wrangler discover . --depth 4 --json
vite-plus-wrangler config workers/api/wrangler.toml --env dev --json
vite-plus-wrangler account-check wrangler.toml --expect <account-id>
vite-plus-wrangler migrations ./migrations --json

All commands accept --json for machine consumption.

Exit codes: 0 success, 1 a finding (account mismatch, migration error, bad config), 2 a usage error. A failure to start the engine also exits non-zero — a guard that could not run never reports success.

Environment variables

| Variable | Purpose | | ----------------------- | -------------------------------------------------------------- | | CLOUDFLARE_ACCOUNT_ID | Compared against the config by the account guard | | WRANGLER_RS_BIN | Absolute path to a wrangler-rs binary, overriding resolution |


Plugin options

| Option | Default | Description | | ----------------- | ------------ | -------------------------------------------------- | | root | Vite root | Directory to scan for wrangler configs | | depth | 6 | Max discovery depth (1–64) | | env | – | Wrangler environment to resolve | | guardAccount | true | Run the account check on buildStart | | expectAccount | config value | Explicit expected account id | | failOnError | true | Fail the build when the guard trips | | checkMigrations | true | Check D1 migration ordering on build | | exposeVars | false | Expose vars as import.meta.env.WRANGLER_* | | devEndpoint | false | Serve GET /__wrangler/config from the dev server |


Dev server endpoint

With devEndpoint: true, GET /__wrangler/config returns the discovered configuration as JSON — useful for dashboards, IDE extensions, and agents that need to reason about bindings without shelling out.

It is off by default because the response describes every Worker in the repo. When enabled, account ids are redacted and requests are refused unless the Host header is localhost, which blocks DNS-rebinding reads from a page in your browser. Even so, do not enable it on a dev server started with --host.


Installation internals

The engine is a native binary. It ships as a set of per-platform packages (@vite-plus-wrangler/darwin-arm64, linux-x64, win32-x64, …) declared as optionalDependencies, so your package manager downloads only the one matching your machine.

On a platform with no prebuilt binary, postinstall builds from source with cargo. If Rust is not installed, the install still succeeds and the engine reports a specific error the first time it is needed. To use a binary you built yourself, set WRANGLER_RS_BIN.


Development

pnpm install
cargo build --release   # required: the integration tests need the engine
pnpm build              # engine + TS bundle
pnpm test               # vitest (unit + integration)
cargo test              # Rust unit tests
pnpm typecheck          # tsc --noEmit
pnpm check              # oxlint + oxfmt

See CONTRIBUTING.md for layout and house rules, SECURITY.md for the threat model, and AUDIT.md for the review this codebase has been through.

License

MIT