rollup-plugin-debug
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

rollup-plugin-debug

Console debug statements that can be pattern toggled at compile time from comments in the code.

npm i rollup-plugin-debug pnpm add rollup-plugin-debug yarn add rollup-plugin-debug

Examples

# web
    # view source example/web.ts

    export {}
    //!? 'hello world'
    const someVar = 123
    //!warn 'warning', someVar
    //!time 'time'
    //!timeEnd 'time'
    console.log('sink', someVar)
    //!> alert('hello')

API

# RollupPluginDebugOptions – Plugin options. src/rollup-plugin-debug.ts#L18

# DebugKind src/rollup-plugin-debug.ts#L39

    keyof Console | "literal" | "?" | ">"

# default(options) – Compile time "debug" plugin for browser builds. src/rollup-plugin-debug.ts#L91

    Enables the following:

//!? 'foo', bar
//!warn 'xyz'
//!time 'bench'
//!> if (x) { ... }

// is compiled to:

console.log('foo', bar)
console.warn('xyz')
console.time('bench')
if (x) { ... }

Along with colored label ids namespaced to the package name + filename (excluding specific common parts like src or lib or dist, configurable).

To enable a namespace, or all it is using the same pattern matching as the debug package:

ROLLUP_DEBUG='some-module:*,other:*,-notthis*' npm run build

Will enable the logs just for these modules. The main difference from the debug package, aside from being compile time rather than runtime, is that in DevTools you get the proper file/line link as the call sites of console.* are in the right place, instead of being one module deep, which would point you to debug.js which was not helpful.

# options  =  {} – RollupPluginDebugOptions

default(options)  =>

    Plugin

Credits

Contributing

Fork or edit and submit a PR.

All contributions are welcome!

License

MIT © 2022 stagas

Readme

Keywords

none

Package Sidebar

Install

npm i rollup-plugin-debug

Weekly Downloads

17

Version

0.2.0

License

MIT

Unpacked Size

68.4 kB

Total Files

19

Last publish

Collaborators

  • stagas