Registry / devops / babel-plugin-console

babel-plugin-console

JSON →
library0.2.1jsnpmunverified

A Babel plugin that adds build-time console helper functions to automatically log function parameters, variables, return values, and parent scope — eliminating manual console.log debugging. Current stable version is 0.2.1, released as a series of patches since 2017. Key differentiator: it requires no runtime changes, works with babel-plugin-macros, and supports both browser and Node environments. Unlike manual logging, it provides structured scope inspection at build time, reducing clutter and context loss.

npm install babel-plugin-console
INSTALL
IMPORT
SIG · BABEL-PLUGIN-CONSO
B
babel-plugin-console
devopsjavascriptv0.2.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

console.scope
console.scope('message')
console.scope()
Used after plugin transformation; not an import but a call.
scope (macro)
import scope from 'babel-plugin-console/scope.macro'
import { scope } from 'babel-plugin-console'
Requires babel-plugin-macros to be configured.
babel-plugin-console (plugin)
plugins: ['console']
plugins: ['babel-plugin-console']
In .babelrc, use the short name 'console'.

Demonstrates basic plugin setup and using console.scope to log function scope details.

// Install: npm install --save-dev babel-plugin-console // .babelrc: { "plugins": ["console"] } // Source code: function greet(name) { const greeting = 'Hello'; console.scope('Greeting function'); return greeting + ' ' + name; } greet('World'); // After Babel transform, output logs: // [console.scope] Greeting function // [console.scope] name: World // [console.scope] greeting: Hello // [console.scope] return: Hello World
Debug
Known issues
gotchaconsole.scope does not log anything in Node for groupCollapse/groupEnd; use plugin version >=0.2.0 for better Node support.
fix
Upgrade to 0.2.0+.
affects: <0.2.0
gotchaMacro import path uses 'babel-plugin-console/scope.macro', not default export. Common mistake is importing from the package root.
fix
Use import scope from 'babel-plugin-console/scope.macro'.
affects: >=0.1.0
breakingIn v0.1.2, import/require statements are removed from the script scope. If you relied on them being logged, they will no longer appear.
fix
Move variable declarations instead of imports for logging purposes.
affects: >=0.1.2
deprecatedThe package is maintained but low activity. No known deprecations, but consider alternatives like babel-plugin-trace if more features are needed.
fix
No action required.
affects: >=0.2.1
Errors
Common errors & fixes
Plugin/Macro not found: 'console'
Missing or incorrect Babel plugin configuration.
fix
Ensure babel-plugin-console is installed and listed in plugins as 'console'.
Cannot find module 'babel-plugin-console/scope.macro'
Macro import path is wrong or babel-plugin-macros not installed.
fix
Install babel-plugin-macros and use exact import path 'babel-plugin-console/scope.macro'.
console.scope is not a function
Plugin not applied before runtime execution or Babel not configured.
fix
Run code through Babel with the plugin enabled.
Upgrade
Version history
0.2.1latest on npm
Audit
Dependencies
babel-plugin-macrosoptionalRequired to use the macro API (scope.macro); plugin mode works without it.
Agent activity
4 hits · last 30 days
node
4
Resources
babel-plugin-console — npm install babel-plugin-console · libregistry