New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

babel-console-source

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-console-source

A Babel plugin that automatically prepends the source file and line number to console.log calls.

latest
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

Babel Plugin: Console Source A Babel plugin that automatically prepends the source file and line number to console.log calls, making your debugging experience infinitely better.

The Problem We all use console.log() to debug, but in a large application, your console can quickly fill up with messages. It becomes difficult to know where each log is coming from without manually adding identifying strings to every single call.

// Where did this come from? Which component? Which file? console.log('Data updated', newData);

The Solution This Babel plugin automatically transforms your code at build time to add the source location to every console.log call.

Your code (before):

// In src/components/UserProfile.js console.log("User loaded", user);

What Babel outputs (after):

// The plugin automatically adds the file and line number! console.log("[UserProfile.js:42]", "User loaded", user);

This provides incredible debugging context for free, with zero effort.

Installation npm install --save-dev @your-username/babel-plugin-console-source

Usage In your Babel configuration file (babel.config.js or .babelrc), add the plugin to your plugins array. It's often best to only enable this during development.

// babel.config.js module.exports = api => { // Use api.env() to check the current environment const isDevelopment = api.env('development');

return { presets: [ // ... your other presets ], plugins: [ // Only apply the plugin in the development environment isDevelopment && '@your-username/babel-plugin-console-source', // ... your other plugins ].filter(Boolean), // .filter(Boolean) removes any falsey values }; };

Keywords

babel

FAQs

Package last updated on 20 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts