
Product
Introducing Repository Access Permissions and Custom Roles
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.
unplugin-dbg
Advanced tools
In your code, just use dbg like this:
dbg(): voiddbg(expr): exprdbg(expr, expr2, expr3): [expr, expr2, expr3]function sum(a: number, b: number) {
const [res, _a, _b] = dbg(a + b, a, b);
return res;
}
const result = dbg(sum(10, 5));
console.log('From console.log!:', result);
// Output:
// [script.ts:2:25] a + b = 15
// [script.ts:2:25] a = 10
// [script.ts:2:25] b = 5
// [script.ts:6:16] sum(10, 5) = 15
// From console.log!: 15

# npm
npm i unplugin-dbg
# pnpm
pnpm i unplugin-dbg
# yarn
yarn add unplugin-dbg
(Optional) Add types to your tsconfig.json if you use TypeScript:
{
"compilerOptions": {
"types": ["unplugin-dbg/globals"]
}
}
Add the plugin to your bundler config:
// vite.config.ts
import dbg from 'unplugin-dbg/vite';
export default defineConfig({
plugins: [
dbg({
/* options */
}),
],
});
// rollup.config.js
import dbg from 'unplugin-dbg/rollup';
export default {
plugins: [
dbg({
/* options */
}),
],
};
// webpack.config.js
module.exports = {
/* ... */
plugins: [
require('unplugin-dbg/webpack')({
/* options */
}),
],
};
// nuxt.config.js
export default defineNuxtConfig({
modules: [
[
'unplugin-dbg/nuxt',
{
/* options */
},
],
],
});
This module works for both Nuxt 2 and Nuxt Vite
// vue.config.js
module.exports = {
configureWebpack: {
plugins: [
require('unplugin-dbg/webpack')({
/* options */
}),
],
},
};
// esbuild.config.js
import { build } from 'esbuild';
import dbg from 'unplugin-dbg/esbuild';
build({
plugins: [dbg()],
});
import type { Options as SwcOptions } from '@swc/core';
export interface Options {
/**
* Whether to enable the plugin.
*
* @default true
*/
enabled?: boolean;
/**
* Base options for SWC.
*/
baseSwcOptions?: SwcOptions | ((code: string, id: string) => SwcOptions);
}
See more about the swc plugin options here.
// Use the plugin with SWC
swc.transform(code, {
jsc: {
experimental: {
plugins: [
[
'unplugin-dbg/swc-plugin',
{
enabled: true, // Required
},
],
],
},
},
});
// Use `dbg` manually
import { _ as dbg } from 'unplugin-dbg/runtime';
// Without location context
dbg.call(
null,
{
expr: '<expr>',
value: expr,
},
{
expr: '10 + 5',
value: 10 + 5,
}
// ...
);
// With location context
dbg.call(
{
file: 'script.ts',
line: 1,
col: 1,
},
{
expr: '<expr>',
value: expr,
},
{
expr: '10 + 5',
value: 10 + 5,
}
// ...
);
FAQs
Rust's `dbg!` for JavaScript, logging values with context effortlessly.
The npm package unplugin-dbg receives a total of 290 weekly downloads. As such, unplugin-dbg popularity was classified as not popular.
We found that unplugin-dbg demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.

Product
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.