@ts-delight/debug.macro
    TypeScript icon, indicating that this package has built-in type declarations

    2.0.0 • Public • Published

    About

    debug is nice utility for debug logging. This babel macro adds a few opinionated conveniences on top of debug library.

    1. Enforces the convention that debug scope is derived from filesystem hierarchy. So my-package/lib/decorators/foo.js will automatically use require('debug')("my-package:lib:decorators:foo");
    2. Line number & timestamp is prefixed in all debug logs.
    3. Utility to debug variable and members expressions without duplication: debug.vars(a, b.c, d) compiles to debug('a:', a, 'b.c:', b.c, 'd:', d).
    4. Utility (debug.allInScope()) to debug all variables declared in block scope (whenever they are initialized or reassigned)
    5. Utility (debug.all()) to debug all variables in current file.

    Examples: [1], [2], [3].

    Installation

    This utility is implemented as a babel-macro.

    Refer babel's setup instructions to learn how to setup your project to use babel for compilation. Usage with tsc (only) is not supported.

    1. Install babel-plugin-macros and debug.macro:
    npm install --save-dev babel-plugin-macros @ts-delight/debug.macro
    1. Add babel-plugin-macros to .babelrc (if not already preset):
    // .babelrc
     
    module.exports = {
      presets: [
        '@babel/preset-typescript',
        // ... other presets
      ],
      plugins: [
        'babel-plugin-macros',
        // ... other plugins
      ],
    };

    License

    MIT

    Install

    npm i @ts-delight/debug.macro

    DownloadsWeekly Downloads

    3

    Version

    2.0.0

    License

    MIT

    Unpacked Size

    12.5 kB

    Total Files

    6

    Last publish

    Collaborators

    • lorefnon