# extract-di-webpack-plugin

> Webpack plugin for static dependency injection analysis

Latest version **5.0.1** (published 2016-12-13) · ISC license · 0 weekly downloads

## Install

```sh
npm install extract-di-webpack-plugin
pnpm add extract-di-webpack-plugin
yarn add extract-di-webpack-plugin
bun add extract-di-webpack-plugin
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.0.1 |
| Published | 2016-12-13 |
| First published | 2016-08-29 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | jakwuh |
| Maintainers | jakwuh |

## Links

- npm: https://www.npmjs.com/package/extract-di-webpack-plugin
- Repository: https://github.com/jakwuh/extract-di-webpack-plugin
- Homepage: https://github.com/jakwuh/extract-di-webpack-plugin#readme
- Issues: https://github.com/jakwuh/extract-di-webpack-plugin/issues
- npm.io page: https://npm.io/package/extract-di-webpack-plugin

## Dependencies (2)

- [lodash](https://npm.io/package/lodash.md) ^4.15.0
- [babel-core](https://npm.io/package/babel-core.md) ^5.8.38

## Recent versions

- 5.0.1 (latest) — 2016-12-13
- 5.0.0 — 2016-08-29

## README

# extract-di-webpack-plugin [![Build Status](https://travis-ci.org/jakwuh/extract-di-webpack-plugin.svg?branch=master)](https://travis-ci.org/jakwuh/extract-di-webpack-plugin)

## Installation

```bash
npm i -S extract-di-webpack-plugin
```

## Usage:

### Step 1

Add plugin to webpack config:
```js
// webpack.config.js
const ExtractDIPlugin = require('extract-di-webpack-plugin');

module.exports = {
    // ...
    plugins: [
        // ...
        new ExtractDIPlugin()
    ]
    
 }

```

ExtractDIPlugin accepts 2 arguments:

```js
/**
 * @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:

```js
// 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](https://github.com/jakwuh/babel-plugin-extract-dependency-definitions) to export definitions automatically.

### Step 3

Now you can require parsed definitions anywhere you want. 

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

---
_Source: https://npm.io/package/extract-di-webpack-plugin · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
