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

@opencookies/vite

v0.0.2

Published

Vite plugin for OpenCookies. Runs `@opencookies/scanner` against your source on dev start and on every HMR update, and surfaces ungated cookie writes / vendor calls as Vite warnings — or build failures.

Readme

@opencookies/vite

Vite plugin for OpenCookies. Runs @opencookies/scanner against your source on dev start and on every HMR update, and surfaces ungated cookie writes / vendor calls as Vite warnings — or build failures.

Install

bun add -D @opencookies/vite @opencookies/scanner @opencookies/core

Usage

// vite.config.ts
import { defineConfig } from "vite";
import { openCookies } from "@opencookies/vite";

export default defineConfig({
  plugins: [
    openCookies({
      config: {
        categories: [
          { key: "necessary", label: "Necessary", locked: true },
          { key: "analytics", label: "Analytics" },
          { key: "marketing", label: "Marketing" },
        ],
      },
    }),
  ],
});

Options

| Option | Type | Default | Description | | ---------- | ---------------------------- | ----------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | | config | OpenCookiesConfig | required | The runtime consent config used at runtime. The plugin uses categories[].key to know which categories are covered when autoSync is enabled. | | mode | "warn" \| "error" \| "off" | "warn" in dev, "error" in build | Controls how findings are reported. error causes vite build to fail when ungated findings remain. off skips scanning entirely. | | include | string[] | scanner default | Forwarded to the scanner. | | exclude | string[] | scanner default | Forwarded to the scanner. | | rules | Rule[] | defaultRules | Override the rule set. | | vendors | VendorRegistry | defaultVendors | Override the vendor registry. | | autoSync | boolean | false | When true, prints a copy-pasteable list of vendor categories that are missing from your config.categories. |

Modes

  • warn (dev default): prints findings via Vite's logger. Does not fail the dev server.
  • error (build default): same console output, plus throws at buildEnd if any ungated findings remain — so CI fails.
  • off: scanner does not run.

Output

Each ungated finding is printed as:

[opencookies] ungated google-analytics (analytics) call via global at src/app.tsx:12:3
  Rule: vendor-imports
  Fix: wrap call sites in <ConsentGate category="…"> or guard with store.has("category")
  Suppress: // opencookies-ignore-next-line

A summary line follows: [opencookies] N cookies, M vendors, K ungated.

HMR

On every save, the plugin re-runs the scanner against the changed file only (no full project re-scan). Findings added or cleared by the edit are logged inline. The incremental path stays under 50 ms on typical files.

autoSync

autoSync: true flags vendor categories your scan detected that are not yet declared in config.categories. The plugin prints a suggested snippet — it does not write to disk. Persisted sync (writing to your config file) is handled by @opencookies/cli.

Suppression

Inherits the scanner's comment syntax:

// opencookies-ignore-next-line
gtag("event", "ad_view");

Or per-file (must appear in the first 10 lines):

// opencookies-ignore-file

Compatibility

Compatible with Vite 5 and 6. Framework-agnostic — works with React, Vue, Svelte, SolidStart, SvelteKit, Astro, Nuxt 3, and Remix because the plugin only consumes file paths and source text.

See also

License

Apache-2.0