{"id":19035,"library":"babel-plugin-console","title":"babel-plugin-console","description":"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.","status":"active","version":"0.2.1","language":"javascript","source_language":"en","source_url":"https://github.com/mattphillips/babel-plugin-console","tags":["javascript","babel","plugin","babel-plugin","console","scope","babel-plugin-macros"],"install":[{"cmd":"npm install babel-plugin-console","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-console","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-console","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required to use the macro API (scope.macro); plugin mode works without it.","package":"babel-plugin-macros","optional":true}],"imports":[{"note":"Used after plugin transformation; not an import but a call.","wrong":"console.scope()","symbol":"console.scope","correct":"console.scope('message')"},{"note":"Requires babel-plugin-macros to be configured.","wrong":"import { scope } from 'babel-plugin-console'","symbol":"scope (macro)","correct":"import scope from 'babel-plugin-console/scope.macro'"},{"note":"In .babelrc, use the short name 'console'.","wrong":"plugins: ['babel-plugin-console']","symbol":"babel-plugin-console (plugin)","correct":"plugins: ['console']"}],"quickstart":{"code":"// Install: npm install --save-dev babel-plugin-console\n// .babelrc:\n{\n  \"plugins\": [\"console\"]\n}\n\n// Source code:\nfunction greet(name) {\n  const greeting = 'Hello';\n  console.scope('Greeting function');\n  return greeting + ' ' + name;\n}\n\ngreet('World');\n\n// After Babel transform, output logs:\n// [console.scope] Greeting function\n// [console.scope] name: World\n// [console.scope] greeting: Hello\n// [console.scope] return: Hello World","lang":"javascript","description":"Demonstrates basic plugin setup and using console.scope to log function scope details."},"warnings":[{"fix":"Upgrade to 0.2.0+.","message":"console.scope does not log anything in Node for groupCollapse/groupEnd; use plugin version >=0.2.0 for better Node support.","severity":"gotcha","affected_versions":"<0.2.0"},{"fix":"Use import scope from 'babel-plugin-console/scope.macro'.","message":"Macro import path uses 'babel-plugin-console/scope.macro', not default export. Common mistake is importing from the package root.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Move variable declarations instead of imports for logging purposes.","message":"In v0.1.2, import/require statements are removed from the script scope. If you relied on them being logged, they will no longer appear.","severity":"breaking","affected_versions":">=0.1.2"},{"fix":"No action required.","message":"The package is maintained but low activity. No known deprecations, but consider alternatives like babel-plugin-trace if more features are needed.","severity":"deprecated","affected_versions":">=0.2.1"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Ensure babel-plugin-console is installed and listed in plugins as 'console'.","cause":"Missing or incorrect Babel plugin configuration.","error":"Plugin/Macro not found: 'console'"},{"fix":"Install babel-plugin-macros and use exact import path 'babel-plugin-console/scope.macro'.","cause":"Macro import path is wrong or babel-plugin-macros not installed.","error":"Cannot find module 'babel-plugin-console/scope.macro'"},{"fix":"Run code through Babel with the plugin enabled.","cause":"Plugin not applied before runtime execution or Babel not configured.","error":"console.scope is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}