# babel-plugin-externals

> 将es module中的import语句代码编译为引用全局变量，如下示例所示，配置的externals选项为

Latest version **0.0.4** (published 2022-01-04) · 0 weekly downloads

## Install

```sh
npm install babel-plugin-externals
pnpm add babel-plugin-externals
yarn add babel-plugin-externals
bun add babel-plugin-externals
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2022-01-04 |
| First published | 2022-01-04 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | martsforever |

## Links

- npm: https://www.npmjs.com/package/babel-plugin-externals
- npm.io page: https://npm.io/package/babel-plugin-externals

## Recent versions

- 0.0.4 (latest) — 2022-01-04
- 0.0.3 — 2022-01-04
- 0.0.2 — 2022-01-04
- 0.0.1 — 2022-01-04

## README

# babel-plugin-externals

将es module中的import语句代码编译为引用全局变量，如下示例所示，配置的externals选项为

```js
# externals
const options = {vue: 'Vue', react: 'React', 'react-dom': 'ReactDOM'}
```

```js
import {renderList as _renderList, Fragment as _Fragment} from "vue"

console.log(_renderList, _Fragment)

// 不在externals排除选项中，跳过
import {defineConfig} from "vite"

console.log(defineConfig)

import * as VUE from "vue"

console.log(VUE)

import Vue, {Abc as abc} from "vue"

console.log(Vue, abc)
```

转换后

```js
const {
    renderList: _renderList,
    Fragment: _Fragment
} = Vue;
console.log(_renderList, _Fragment);
import {defineConfig} from "vite";

console.log(defineConfig);
const VUE = Vue;
console.log(VUE);
const Vue = Vue;
const {
    Abc: abc
} = Vue;
console.log(Vue, abc);
```

> 不会影响export语句代码

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