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-plugin-cooked

v1.0.1

Published

Vite's ?raw gives you uncooked source. This gives you the cooked version — compiled, bundled, and tree-shaken.

Readme


Why

// ?raw → uncooked: types, JSX, and imports stay as-is. Can't run in a browser.
import raw from './worker.ts?raw'

// ?to=js → cooked: compiled to JS, all deps bundled in, tree-shaken. Ready to execute.
import cooked from './worker.ts?to=js'

Install

npm install -D vite-plugin-cooked

Setup

// vite.config.ts
import { defineConfig } from 'vite'
import cooked from 'vite-plugin-cooked'

export default defineConfig({
  plugins: [cooked()],
})

Usage

import code from './worker.ts?to=js'                          // bundle + compile to JS
import min from './worker.ts?minify&to=js'                    // + minify
import iife from './worker.ts?format=iife&minify&to=js'       // IIFE for Workers / <script>
import lite from './widget.tsx?external=react,react-dom&to=js' // keep react as import
import all from './lib.ts?external=*&to=js'                   // keep all bare imports
import raw from './utils.ts?nobundle&to=js'                   // single-file transpile only

TypeScript tip: Put to=js / to=ts last in the query. The type declarations use *to=js patterns — ?minify&to=js matches, ?to=js&minify does not.

Query Parameters

| Param | Values | Description | |-------|--------|-------------| | to | js, ts | Target format. js strips types and compiles JSX. | | minify | flag | Minify the output. | | target | e.g. es2020 | Syntax downleveling target. | | banner | string | Text prepended to output (URL-encode special chars). | | format | es, iife | Output format. Default es. iife for Workers / scripts. | | external | pkg names or * | Deps to exclude from bundle, comma-separated. * = all bare imports. | | nobundle | flag | Skip bundling — transpile only, imports preserved. |

Options

cooked({
  defaultTarget: 'es2020',
  defaultMinify: false,
  defaultFormat: 'es',
  defaultExternal: ['react', 'react-dom'],
})

TypeScript

{
  "compilerOptions": {
    "types": ["vite-plugin-cooked/client"]
  }
}

Bundle vs Nobundle

| | Bundle (default) | Nobundle (&nobundle) | |---|---|---| | Imports | Resolved, inlined, tree-shaken | Preserved as-is | | Output | Self-contained | Single-file transpile | | Speed | Slower (full build) | Fast |

FAQ

How is this different from ?worker? ?worker returns a Worker constructor from a separate file. cooked returns a code string — you control where it runs: Worker, iframe, <script>, sandbox.

Isn't ?raw enough? ?raw returns uncompiled source. TypeScript types, JSX, and bare imports can't execute in a browser. cooked compiles and bundles first.

Can I cook .vue / .svelte files? Not yet. The internal build uses configFile: false and doesn't load framework plugins.

Limitations

  • Dep changes don't trigger HMR — only the entry file is watched. Re-save entry or restart dev server.
  • CSS imports are ignored — cooked outputs a string, CSS has nowhere to inject. A warning is logged.
  • No source maps — output is a string constant. Use &nobundle for easier debugging.
  • Dynamic imports break — no separate chunks exist after bundling. Use static imports only.
  • import.meta.url changes — points to blob/injection URL, not the original file.
  • ?to=ts requires &nobundle — bundle mode always compiles to JS.
  • &external=* + &format=iife — not supported. IIFE needs explicit globals mapping.
  • Build perf — each cooked import runs a full vite.build(). Results are cached and concurrency is capped at 3.

Compatibility

| Vite | Behavior | |------|----------| | 4 – 7 | transformWithEsbuild for nobundle transforms | | 8+ | transformWithOxc when available, esbuild fallback for minification |

License

MIT