0.2.0 • Published 2 years ago

rollup-plugin-debug v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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

Examples

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

API

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.

Credits

Contributing

Fork or edit and submit a PR.

All contributions are welcome!

License

MIT © 2022 stagas