# babel-plugin-esm-rewrite

Latest version **0.0.0** (published 2022-01-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install babel-plugin-esm-rewrite
pnpm add babel-plugin-esm-rewrite
yarn add babel-plugin-esm-rewrite
bun add babel-plugin-esm-rewrite
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.0 |
| Published | 2022-01-23 |
| First published | 2022-01-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 19 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 43 |
| Author | Anthony Fu <anthonyfu117@hotmail.com> |
| Maintainers | antfu |

## Links

- npm: https://www.npmjs.com/package/babel-plugin-esm-rewrite
- Repository: https://github.com/antfu/babel-plugin-esm-rewrite
- Homepage: https://github.com/antfu/babel-plugin-esm-rewrite#readme
- Issues: https://github.com/antfu/babel-plugin-esm-rewrite/issues
- Funding: https://github.com/sponsors/antfu
- npm.io page: https://npm.io/package/babel-plugin-esm-rewrite

## Dependencies (1)

- [@babel/helper-plugin-utils](https://npm.io/package/@babel/helper-plugin-utils.md) ^7.16.7

## Recent versions

- 0.0.0 (latest) — 2022-01-23

## README

# babel-plugin-esm-rewrite

[![NPM version](https://img.shields.io/npm/v/babel-plugin-esm-rewrite?color=a1b858&label=)](https://www.npmjs.com/package/babel-plugin-esm-rewrite)

Rewrites ESM syntax to function calls, so they can be evaluated without ESM context. Ported from [Vite's ssrTransfrom](https://github.com/vitejs/vite/blob/main/packages/vite/src/node/ssr/ssrTransform.ts) but as a Babel plugin.

```js
// input
import { ref } from 'vue'
function foo() {
  return ref(0)
}
```

```ts
// output
const __esm_import_0__ = await __esm_import__('vue')
function foo() {
  return __esm_import_0__.ref(0)
}
```

## Sponsors

<p align="center">
  <a href="https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg">
    <img src='https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg'/>
  </a>
</p>

## License

[MIT](./LICENSE) License © 2022 [Anthony Fu](https://github.com/antfu)

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