# esmodules-webpack-plugin

> Build an extra JavaScript for ESModules.

Latest version **0.0.5** (published 2019-05-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install esmodules-webpack-plugin
pnpm add esmodules-webpack-plugin
yarn add esmodules-webpack-plugin
bun add esmodules-webpack-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.5 |
| Published | 2019-05-09 |
| First published | 2019-03-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6.9 |
| Dependencies | 1 |
| Unpacked size | 15.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Anson Huang |
| Maintainers | ansenhuang |
| Keywords | webpack, plugin, esmodules, esmodules-webpack-plugin |

## Links

- npm: https://www.npmjs.com/package/esmodules-webpack-plugin
- Repository: https://github.com/ansenhuang/esmodules-webpack-plugin
- Issues: https://github.com/ansenhuang/esmodules-webpack-plugin/issues
- npm.io page: https://npm.io/package/esmodules-webpack-plugin

## Dependencies (1)

- [loader-utils](https://npm.io/package/loader-utils.md) ^1.2.3

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 0.0.5 (latest) — 2019-05-09
- 0.0.4 — 2019-04-05
- 0.0.3 — 2019-04-02
- 0.0.2 — 2019-04-01
- 0.0.1 — 2019-03-31
- 0.0.0 — 2019-03-29

## README

<div align="center">
  <a href="https://github.com/webpack/webpack">
    <img width="200" height="200" src="https://webpack.js.org/assets/icon-square-big.svg">
  </a>
</div>

[![npm][npm]][npm-url]
[![node][node]][node-url]
[![downloads][downloads]][npm-url]
[![deps][deps]][deps-url]
<!-- [![tests][tests]][tests-url] -->

# esmodules-webpack-plugin

This plugin build an extra JavaScript for ESModules, it supports loading with `<script type="module" src="..."></script>`.

## Getting Started

To begin, you'll need to install `esmodules-webpack-plugin`:

```console
$ npm install esmodules-webpack-plugin --save-dev
```

Then add the plugin to your `webpack` config. For example:

**webpack.config.js**

```js
const ESModulesWebpackPlugin = require('esmodules-webpack-plugin');

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

And run `webpack` via your preferred method.

## Features

* Build completely different files for both modern and legacy browsers
* Avoid rebuilding the assets except JavaScript
* Support html-webpack-plugin and inject scripts automatically
* ...

## Options

### `webpackConfig`

* Type: `Object`
* Required: `false`

Compile JavaScript for ESModules with this config, the plugin will inject any assets exclude `.js` that you compiled before, so we won't build assets twice.

**tips:** If `webpackConfig` is defined, `webpackOptions` will be ignored.

### `webpackOptions`

* Type: `Object`
* Required: `false`

It also a webpackConfig for ESModules, the difference is that it will merge the defaultConfig which is based on previous config, so it's flexible when you need to load some plugins or options.

### `styleLoader`

* Type: `String|Boolean`
* Required: `false`
* default: development=true, production=false

If `style-loader` was used, please let me know so we can deal with `css` and inject css to js.

## Examples

[Refer to here](./examples)

## License

[MIT](./LICENSE)


[npm]: https://img.shields.io/npm/v/esmodules-webpack-plugin.svg
[npm-url]: https://npmjs.com/package/esmodules-webpack-plugin

[node]: https://img.shields.io/node/v/esmodules-webpack-plugin.svg
[node-url]: https://nodejs.org

[deps]: https://david-dm.org/ansenhuang/esmodules-webpack-plugin.svg
[deps-url]: https://david-dm.org/ansenhuang/esmodules-webpack-plugin

[downloads]: http://img.shields.io/npm/dt/esmodules-webpack-plugin.svg?style=flat-square

[tests]: http://img.shields.io/travis/ansenhuang/esmodules-webpack-plugin.svg
[tests-url]: https://travis-ci.org/ansenhuang/esmodules-webpack-plugin

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