# babel-explode-module

> Serialize a module into an easier format to work with

Latest version **3.0.0** (published 2018-08-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install babel-explode-module
pnpm add babel-explode-module
yarn add babel-explode-module
bun add babel-explode-module
```

## 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 | 3.0.0 |
| Published | 2018-08-10 |
| First published | 2017-05-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 11.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 34 |
| Author | James Kyle |
| Maintainers | thejameskyle |

## Links

- npm: https://www.npmjs.com/package/babel-explode-module
- Repository: https://github.com/thejameskyle/babel-explode-module
- Homepage: https://github.com/thejameskyle/babel-explode-module#readme
- Issues: https://github.com/thejameskyle/babel-explode-module/issues
- npm.io page: https://npm.io/package/babel-explode-module

## Dependencies (1)

- [@babel/types](https://npm.io/package/@babel/types.md) ^7.0.0-beta.56

## Recent versions

- 3.0.0 (latest) — 2018-08-10
- 2.0.0 — 2017-06-29
- 1.4.0 — 2017-06-02
- 1.3.3 — 2017-05-30
- 1.3.2 — 2017-05-30
- 1.3.1 — 2017-05-30
- 1.3.0 — 2017-05-30
- 1.2.1 — 2017-05-25
- 1.2.0 — 2017-05-25
- 1.1.0 — 2017-05-25
- 1.0.1 — 2017-05-17
- 1.0.0 — 2017-05-16

## README

# babel-explode-module

> Serialize a module into an easier format to work with

```js
import {foo, bar} from "mod";

export default function() {
  // ...
}

const baz = 42,
      bat = class Bat {};

export {
  baz,
  bat
};
```

Creating this AST:

```yml
Program
  body:
    - ImportDeclaration
        specifiers:
          - ImportSpecifier
          - ImportSpecifier
    - ExportDefaultDeclaration
        declaration: FunctionDeclaration
    - VariableDeclaration
        declarations:
          - VariableDeclarator
          - VariableDeclarator
    - ExportNamedDeclaration
        specifiers:
          - ExportSpecifier
          - ExportSpecifier
```

Will be exploded to this:

```js
{
  imports: [
    { kind: "value", local: "foo", external: "foo", source: "mod", loc: {...} },
    { kind: "value", local: "bar", external: "bar", source: "mod", loc: {...} },
  ],
  exports: [
    { local: "_default", external: "default", loc: {...} },
    { local: "baz", external: "baz", loc: {...} },
    { local: "bat", external: "bat", loc: {...} },
  },
  statements: [
    { type: "FunctionDeclaration" },
    { type: "VariableDeclaration", declarations: VariableDeclarator },
    { type: "VariableDeclaration", declarations: VariableDeclarator },
  ],
}
```

#### Serializes imports/exports to an easy to work with format

```js
// input
import a, {b} from "mod";
import * as c from "mod";
export default function d() {}
export {e, f as g};
export {default as h} from "mod";
export * from "mod";
```

```js
// output
{
  imports: [
    { kind: "value", local: "a", external: "a", source: "mod" },
    { kind: "value", local: "b", external: "b", source: "mod" },
    { kind: "value", local: "c", source: "d" },
  ],
  exports: [
    { local: "d", external: "d" },
    { local: "e", external: "e" },
    { local: "f", external: "g" },
    { local: "default", external: "g", source: "mod" },
    { source: "mod" },
  ]
}
```

#### Simplifies declarations to create 1 binding per statement (i.e. variables)

```js
// input
function a() {}
var b,
    c;
```

```js
// output (printed)
function a() {}
var b;
var c;
```

#### Splits export values away from their exports

```js
// input
export function a() {}
export default function() {}
```

```js
// output (printed)
function a() {}
var _default = function() {};
export {a};
export default _default;
```

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