extract-di-webpack-plugin

    5.0.1 • Public • Published

    extract-di-webpack-plugin Build Status

    Installation

    npm i -S extract-di-webpack-plugin

    Usage:

    Step 1

    Add plugin to webpack config:

    // webpack.config.js
    const ExtractDIPlugin = require('extract-di-webpack-plugin');
     
    module.exports = {
        // ...
        plugins: [
            // ...
            new ExtractDIPlugin()
        ]
        
     }
     

    ExtractDIPlugin accepts 2 arguments:

    /**
     * @param {string} [moduleName = 'di-definitions] - used for requiring definitions in your code
     * @param {{}} options
     * @param {string} [options.exportName = '__diDefinitions'] - used for parsing definitions from your modules
     */

    Step 2

    In your modules use following syntax to export definitions:

    // module.js
    Object.defineProperty(exports, '__diDefinitions', {
        currentUser: ['User', {
            request: 'Requst'
        }]
    });

    Exported definitions from all modules will be merged into one object and available for requiring from any place of a code.

    Note, it is not necessary to write such definitions manually. Consider using babel-plugin-extract-dependency-definitions to export definitions automatically.

    Step 3

    Now you can require parsed definitions anywhere you want.

    // entry.js
    const definitions = require('di-definitons');

    Keywords

    none

    Install

    npm i extract-di-webpack-plugin

    DownloadsWeekly Downloads

    0

    Version

    5.0.1

    License

    ISC

    Last publish

    Collaborators

    • jakwuh