babel-log

raw JSON →
2.0.0 verified Sat Apr 25 auth: no javascript

babel-log is a lightweight utility for logging Babel AST paths and nodes with clean, colored formatting in the console. As of version 2.0.0, it provides a single default-exported function that accepts any object, making it ideal for debugging Babel plugins. It is in active development with a low release cadence. Unlike manual console.log, babel-log formats complex AST structures for readability.

error TypeError: log is not a function
cause Importing with named import instead of default import.
fix
Use import log from 'babel-log' (without curly braces).
error Cannot find module 'babel-log'
cause Package not installed in project dependencies.
fix
Run npm install babel-log --save-dev
gotcha The function only logs to console and returns undefined; it is not for serialization.
fix Use it only for debugging; do not rely on return value.
npm install babel-log
yarn add babel-log
pnpm add babel-log

This shows how to import and use babel-log inside a Babel plugin to log AST nodes during traversal.

import log from 'babel-log';

export default function myBabelPlugin() {
  return {
    visitor: {
      Identifier(path) {
        log(path.node); // logs the node with pretty formatting
      }
    }
  };
}