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

@autotracer/plugin-babel-flow

v1.0.0-alpha.54

Published

Babel plugin for automatic function flow tracing with try/catch/finally injection

Readme

@autotracer/plugin-babel-flow

Overview

@autotracer/plugin-babel-flow is the AutoTracer build-time plugin for Babel-based apps such as Next.js, Create React App, and custom Babel pipelines. It instruments eligible functions during compilation so Flow tracing can record entry, exit, return values, and exceptions without hand-editing your application code.

For Vite-based apps, use @autotracer/plugin-vite-flow instead: https://docs.autotracer.dev/api/plugin-vite-flow

Why Use It

This package owns build-time instrumentation only. Your app bootstrap still decides whether tracing starts immediately with @autotracer/flow, starts dormant with @autotracer/flow/runtime, and whether the Dashboard is mounted as the normal browser control surface in restricted internal browser builds.

Keep this plugin out of publicly accessible builds. AutoTracer is intended for local development and restricted internal test or QA environments.

flowchart LR
  Babel["Babel config<br/>@autotracer/plugin-babel-flow"] --> Instrument["Instrument eligible functions"]
  Bootstrap["App bootstrap"] --> Immediate["@autotracer/flow<br/>immediate startup"]
  Bootstrap --> Dormant["@autotracer/flow/runtime<br/>dormant startup"]
  Immediate --> Control["Dashboard or globalThis.autoTracer.flowTracer"]
  Dormant --> Control

Installation

pnpm add @autotracer/flow
pnpm add -D @autotracer/plugin-babel-flow @babel/core

If this internal browser app uses the Dashboard as its normal control surface, install it separately:

pnpm add @autotracer/dashboard

@autotracer/logger is installed automatically with @autotracer/flow. @babel/core is the peer dependency required by the Babel plugin.

Configuration

Add the plugin to your Babel configuration:

module.exports = {
  plugins: [
    [
      "@autotracer/plugin-babel-flow",
      {
        outputMode: "copy-paste",
        mode: "opt-out",
        include: {
          paths: ["**/src/**", "**/app/**"],
          functions: ["handle*", "on*", "fetch*"],
        },
      },
    ],
  ],
};

To keep tracing out of publicly accessible production builds on the Babel path, exclude the plugin from the production Babel config itself:

const shouldTrace =
  process.env.NODE_ENV === "development" ||
  process.env.INTERNAL_QA === "true";

module.exports = {
  plugins: [
    ...(shouldTrace
      ? [
          [
            "@autotracer/plugin-babel-flow",
            {
              include: {
                paths: ["src/**"],
              },
            },
          ],
        ]
      : []),
  ],
};

On the Babel path, runtime gating alone is not enough. If the plugin stays enabled in a production build, Babel still emits instrumented code even if you never start the Flow runtime.

Use the Babel plugin to choose what gets instrumented with include, exclude, mode, and the // @trace and // @trace-disable pragmas.

outputMode seeds Flow output formatting when a processed bootstrap module imports @autotracer/flow or @autotracer/flow/runtime, so you do not need a separate globalThis.autoTracer.setOutputMode(...) call for that startup path.

Partial include and exclude objects merge by key. Arrays replace the default value for that key; they are not concatenated.

tracerName changes only the local injected binding name inside transformed modules. It does not rename the runtime control surface on globalThis.autoTracer.

Use these docs for exact option behavior:

  • Flow integration path: https://docs.autotracer.dev/guide/config-flow
  • Babel plugin settings: https://docs.autotracer.dev/reference/build/flow/babel/
  • Babel pragma comments: https://docs.autotracer.dev/reference/build/flow/babel/pragmas
  • Flow runtime settings: https://docs.autotracer.dev/reference/runtime/flow/
  • Flow runtime API: https://docs.autotracer.dev/api/flow
  • Dashboard workflow: https://docs.autotracer.dev/dashboard/webapps

Usage

Add the Babel plugin, then lazy-load one Flow runtime entry before the rest of the app runs:

const shouldLoadFlow = process.env.NODE_ENV === "development";

async function bootstrap(): Promise<void> {
  if (shouldLoadFlow) {
    await import("@autotracer/flow/runtime");
  }

  await import("./app");
}

void bootstrap();

Replace @autotracer/flow/runtime with @autotracer/flow when tracing should start immediately instead of staying dormant at startup.

Use the same environment decision for both the Babel plugin and the runtime import so internal builds get tracing and publicly accessible builds get neither instrumentation nor runtime startup.

In browser-based internal web apps, the Dashboard is the normal control surface when that workflow is mounted. In tests, automation, and other non-Dashboard setups, use globalThis.autoTracer.flowTracer.

Keep runtime imports behind development or internal-QA guards so publicly accessible builds can exclude AutoTracer completely.

Use the guide that matches your entry path when you need full setup examples:

  • Next.js and other Babel builds: https://docs.autotracer.dev/guide/installation-flow-nextjs
  • Flow quick start: https://docs.autotracer.dev/guide/quickstart-flow
  • Flow package page: https://docs.autotracer.dev/api/plugin-babel-flow

Pragma comments give you per-function control inside eligible files:

// @trace
export function checkoutHandler(cartId: string) {
  return `checkout:${cartId}`;
}

// @trace-disable
export function formatLabel(label: string) {
  return label.trim();
}

Advanced Tooling Surface

@autotracer/plugin-babel-flow also exposes the shared helpers used by higher-level Flow tooling:

import {
  DEFAULT_CONFIG,
  normalizeConfig,
  shouldProcessFile,
  type NormalizedBabelPluginFlowConfig,
} from "@autotracer/plugin-babel-flow";

Use these exports when you are building wrappers or tooling around the Babel plugin. Normal app integrations should usually stay on the Babel config path shown above.

Troubleshooting

If functions are not instrumented, confirm that the active Babel config includes @autotracer/plugin-babel-flow for the current environment and that the file and function names match your include and exclude rules.

If there is no console output, check which runtime entry your bootstrap loads. @autotracer/flow starts tracing immediately. @autotracer/flow/runtime installs the same runtime surface but leaves tracing dormant until you start it from the Dashboard or globalThis.autoTracer.flowTracer.start().

If __flowTracer is not defined appears at runtime, the Flow runtime loaded too late. Import @autotracer/flow or @autotracer/flow/runtime before instrumented application modules execute.

License

MIT © Carl Ribbegårdh