Have ideas to improve npm?Join in the discussion! »

    @adonisjs/ioc-transformer
    TypeScript icon, indicating that this package has built-in type declarations

    2.2.1 • Public • Published

    Ioc Transformer

    Typescript transformer to transform import statements to IoC container use calls

    npm-image license-image

    The Ioc container of AdonisJs exposes the use method to resolve dependencies from the container. However, using use and import statements together feels a bit cluttered. This module enables using import statements for IoC container bindings and transforms them to the use call by hooking into the Typescript compiler lifecycle.

    Table of contents

    Usage

    Install the package from npm registry as follows:

    npm i @adonisjs/ioc-transformer

    Pass it to the Typescript compiler as after hook. Following is an example of using it with ts-node.

    const { iocTransformer } = require('@adonisjs/ioc-transformer')
    
    require('ts-node').register({
      transformers: {
        after: [iocTransformer(require('typescript/lib/typescript'), require('./.adonisrc.json'))],
      }
    })

    Install

    npm i @adonisjs/ioc-transformer

    DownloadsWeekly Downloads

    3,860

    Version

    2.2.1

    License

    MIT

    Unpacked Size

    7.51 kB

    Total Files

    7

    Last publish

    Collaborators

    • avatar
    • avatar