# babel-preset-browser-esm

> Babel preset to convert and load ESM in the browser

Latest version **1.0.0-rc** (published 2018-11-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install babel-preset-browser-esm
pnpm add babel-preset-browser-esm
yarn add babel-preset-browser-esm
bun add babel-preset-browser-esm
```

## 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 | 1.0.0-rc |
| Published | 2018-11-07 |
| First published | 2018-11-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 3.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Tim Branyen |
| Maintainers | tbranyen |
| Keywords | babel, preset, esm, browser |

## Links

- npm: https://www.npmjs.com/package/babel-preset-browser-esm
- npm.io page: https://npm.io/package/babel-preset-browser-esm

## Dependencies (6)

- [@babel/helper-plugin-utils](https://npm.io/package/@babel/helper-plugin-utils.md) ^7.0.0
- [babel-plugin-transform-commonjs](https://npm.io/package/babel-plugin-transform-commonjs.md) ^1.1.0
- [@babel/plugin-proposal-class-properties](https://npm.io/package/@babel/plugin-proposal-class-properties.md) ^7.1.0
- [babel-plugin-resolve-imports-for-browser](https://npm.io/package/babel-plugin-resolve-imports-for-browser.md) ^1.0.0
- [babel-plugin-minify-dead-code-elimination](https://npm.io/package/babel-plugin-minify-dead-code-elimination.md) ^0.5.0
- [babel-plugin-transform-inline-environment-variables](https://npm.io/package/babel-plugin-transform-inline-environment-variables.md) ^0.4.3

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.0.0-rc (latest) — 2018-11-07

## README

# Babel Preset: Browser ESM

[![Build Status](https://travis-ci.org/tbranyen/babel-plugin-resolve-imports.svg?branch=master)](https://travis-ci.org/tbranyen/babel-plugin-resolve-imports)

A Babel 7 compatible preset to fully support loading modules as ESM in the
browser natively. This preset will:

- Automatically inline environment variables
- Runs dead code elimination
- Transforms CommonJS to ESM
- Converts global imports to relative paths using `require.resolve`
- Adds missing `.js` extension

### Usage

```sh
npm install --save-dev babel-preset-browser-esm
```

Update your babel configuration, ensure you use `babel.config.js` over
`.babelrc` to ensure `node_modules` get properly updated:

```javascript
module.exports = {
  presets: ['browser-esm']
};
```

### Run server

This module pairs very nicely with [bserve](https://github.com/tbranyen/bserve)
to run a static server and automatically transpile the JavaScript files.

---
_Source: https://npm.io/package/babel-preset-browser-esm · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
