# exports-library-plugin

> Webpack plugin to preserve ESM import syntax in consuming libraries.

Latest version **0.0.4** (published 2021-11-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install exports-library-plugin
pnpm add exports-library-plugin
yarn add exports-library-plugin
bun add exports-library-plugin
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2021-11-22 |
| First published | 2021-11-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 12.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | alancnet |

## Links

- npm: https://www.npmjs.com/package/exports-library-plugin
- npm.io page: https://npm.io/package/exports-library-plugin

## Recent versions

- 0.0.4 (latest) — 2021-11-22
- 0.0.3 — 2021-11-22
- 0.0.2 — 2021-11-22
- 0.0.1 — 2021-11-22

## README

# Webpack ExportsLibraryPlugin

I threw this together because Node 14+ supports ESM style imports against CommonJS modules,
but only if exports are directly assigned to `exports`, but not if `exports` is reassigned.

Webpack reassigns `exports` for some reason, so resulting libraries don't work this way.

This plugin will add code to export the library in a node-friendly way.

## Usage

```
npm install --save-dev exports-library-plugin
```

In `webpack.config.js`, either in `entry[name]` or in `output`:

```javascript
library: {
  name: 'exports',
  type: 'assign-properties'
}
```

Then

```javascript
const ExportsLibraryPlugin = require('exports-library-plugin')

module.exports = {
  plugins: [
    new ExportsLibraryPlugin()
  ]
}
```

This will preserve the ability to import from the resulting library.

Cheers!!

PS: If someone from Webpack would like to do this properly, I would greatly appreciate it!

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