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

bun-plugin-civet-sourcemaps

v0.0.2

Published

Bun bundler plugin that maps compiled Civet/TSX back to original .civet source files

Readme

bun-plugin-civet-sourcemaps

Unpublished 0.0.2 release candidate (dev.0) — a Bun bundler plugin that preserves original .civet locations after Civet → TypeScript/TSX → JavaScript compilation.

The previously published 0.0.1 release is immutable. Changes and fixes in this candidate belong to 0.0.2.

This is a real Bun BunPlugin, not a wrapper around Bun.build(). It uses onLoad to compile Civet with an inline source map and onEnd to compose Bun's output source maps with each Civet input map. No separate postbuild command or source-map library is needed.

Quick start

Install the package (from the accompanying local tarball until it is published) and Civet:

bun add -d @danielx/civet ./bun-plugin-civet-sourcemaps-0.0.2.tgz

Create build.mjs:

import { civetSourceMaps } from 'bun-plugin-civet-sourcemaps';

const result = await Bun.build({
  entrypoints: ['./src/main.civet'],
  outdir: './dist',
  target: 'browser',
  sourcemap: 'linked',
  plugins: [civetSourceMaps()],
});

if (!result.success) throw new AggregateError(result.logs, 'Build failed');

Then run bun build.mjs. With sourcemap: 'linked', DevTools receives dist/main.js and dist/main.js.map; mapped generated positions should refer to the original .civet source. sourcemap: 'external' works too, but doesn't append a sourceMappingURL comment.

API

civetSourceMaps({
  // optional; default: lazy import of @danielx/civet's `compile`
  compile?: (source: string, options: object) => string | Promise<string>,
  // options passed through to Civet, e.g. { comptime: false }
  compileOptions?: object,
  // default: /\.civet$/
  filter?: RegExp,
})

comptime defaults to true (matching Civet’s Bun plugin); set compileOptions: { comptime: false } to disable it. filename, outputFilename, inlineMap: true, and sourceMap: false are forced to ensure reliable map generation and a string compiler return. filter must not have global or sticky flags.

This plugin replaces Civet's existing Bun onLoad handler when used with Bun.build(). Do not install two .civet handlers for the same files. It is not a preload-time source-map solution for bun file.civet.

What it does

  1. onStart: clear the per-build registry.
  2. onLoad: read .civet, invoke Civet, record its inline Source Map v3, return TSX source to Bun.
  3. Bun bundles and creates its usual intermediate-TSX-based source map.
  4. onEnd: match input files individually, compose each final map, and rewrite the emitted .js.map files before Bun.build() resolves.
  5. Unmodified TypeScript/JavaScript input mappings remain untouched; sourcesContent embeds original Civet text.

A missing compiler map, unsupported source map, absent output map, or disabled sourcemap causes an error rather than silently publishing incorrect debug positions.

Testing

The supplied Bun Linux x64 1.4.4 binary was used for integration tests:

bun test
bun tests/integration.test.mjs

Unit tests exercise Base64 VLQ and map composition. Simulated-compiler integration tests exercise Bun's actual onLoad/onEnd, multiple .civet modules, .ts input, multiple entrypoints, minification, repeated builds, linked/external maps, and failures. The compiler used in tests is a simulated Civet compiler with legitimate Source Map v3 output.

Real-compiler integration tests also run with @danielx/[email protected], loaded from the user-supplied tarball, covering linked/external maps, minification, multiple entrypoints, sequential reuse, comptime override, JSX, and Unicode source preservation. JSX compilation in a dependency-free fixture marks react/jsx-runtime and react/jsx-dev-runtime as external; a production JSX app needs a compatible JSX runtime installed. Note: Bun 1.4.4 does not necessarily emit mappings for every generated JSX child literal. Missing downstream mapping segments are kept unmapped rather than assigned speculative Civet positions.

Current constraints

  • Requires Bun.build({ sourcemap: 'linked' | 'external' }) and disk writes. No sourcemap: 'inline' or write: false support.
  • Bun onEnd is a bundler lifecycle hook, so this does not add runtime bun run source-map support.
  • Source Map v3 standard (not indexed/sectioned maps); the small in-house composer supports common local filesystem sources but is not a production-hardened implementation of URL/Windows/indexed maps or source-map edge cases.
  • Compiled input paths are matched against Bun's output map paths; real Civet 0.11.16 matching is verified on Linux but Windows paths and unusual source roots remain unverified.
  • Watch/incremental builds must trigger a new Bun build so onEnd runs again. Bun's own watcher may need special handling for plugin-loaded files.
  • Other plugins with overlapping onLoad filters can conflict. When chaining other transforms, each intermediate stage needs its own upstream mapping.

Package contents

The npm tarball contains src/, README.md, and LICENSE, not internal handoff docs or tests. The separate development source ZIP contains tests, examples, and HANDOFF.md.