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

swc-plugin-source-tracker

v0.1.1

Published

SWC plugin that injects data-source attributes with file:line:col into JSX DOM elements. Replaces React 19's removed __debugSource. Works with Next.js 15/16 + Turbopack.

Readme

swc-plugin-source-tracker

SWC plugin that injects data-source attributes into JSX DOM elements at compile time.

Each attribute contains the file path, line number, and column where the element was defined in source code.

<!-- Before -->
<div className="card">
  <h2>Title</h2>
  <p>Content</p>
</div>

<!-- After -->
<div className="card" data-source="app/page.tsx:12:5">
  <h2 data-source="app/page.tsx:13:7">Title</h2>
  <p data-source="app/page.tsx:14:7">Content</p>
</div>

Why?

React 19 removed fiber._debugSource, breaking all click-to-source tools (react-dev-inspector, LocatorJS, click-to-component, etc.).

This plugin provides a build-time alternative that works with Next.js 15, 16, Turbopack, and standalone @swc/core.

Install

npm install swc-plugin-source-tracker

Usage with Next.js

// next.config.mjs
import { withSourceTracker } from "swc-plugin-source-tracker";

const nextConfig = {
  experimental: {
    swcPlugins: [withSourceTracker()],
  },
};

export default nextConfig;

That's it. The plugin auto-detects your Next.js version and selects the compatible WASM binary.

Dev-only

You probably want this in development only:

// next.config.mjs
import { withSourceTracker } from "swc-plugin-source-tracker";

const nextConfig = {
  experimental: {
    swcPlugins: [
      ...(process.env.NODE_ENV === "development" ? [withSourceTracker()] : []),
    ],
  },
};

export default nextConfig;

Options

withSourceTracker(
  // Plugin config (passed to SWC)
  { attr: "data-source" },    // Custom attribute name (default: "data-source")

  // JS options
  { version: "v54" },         // Force specific swc_core version: "v35" | "v54"
);

Usage with @swc/core (standalone)

import { getWasmPath } from "swc-plugin-source-tracker";

const result = await swc.transform(code, {
  filename: "src/App.tsx",
  jsc: {
    parser: { syntax: "typescript", tsx: true },
    experimental: {
      plugins: [[getWasmPath(), {}]],
    },
  },
});

Compatibility

| WASM | swc_core | Next.js | Bundler | |------|----------|---------|---------| | v35 | 35.0.0 | 15.x | Webpack | | v54 | 54.0.0 | 16.x | Turbopack |

withSourceTracker() auto-selects the correct version based on your installed Next.js.

How it works

  1. An SWC WASM plugin visits every JSX opening element during compilation
  2. For intrinsic DOM elements (div, span, button, etc.), it injects a data-source attribute
  3. The value contains filename:line:column resolved from SWC's source map
  4. Custom components (<MyComponent>) are skipped — they render DOM elements that get annotated

Reading source info at runtime

Open DevTools and inspect any element to see its data-source attribute, or:

// Paste in browser console
document.addEventListener("click", (e) => {
  const src =
    e.target.getAttribute("data-source") ||
    e.target.closest("[data-source]")?.getAttribute("data-source");
  if (src) console.log(e.target.tagName, "→", src);
}, true);

.gitignore

The plugin copies a WASM file to your project root for Turbopack compatibility. Add this to .gitignore:

swc_plugin_source_tracker.wasm

License

MIT