Skip to content

Commit

Permalink
add docs for @babel/plugin-syntax-module-string-names (#2396)
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Oct 19, 2020
1 parent 29195c4 commit 3b3e7f5
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions docs/plugin-syntax-module-string-names.md
@@ -0,0 +1,56 @@
---
id: babel-plugin-syntax-module-string-names
title: @babel/plugin-syntax-module-string-names
sidebar_label: syntax-module-string-names
---

## Example

This plugin enables `@babel/parser` to parse

```js
export { smile as "😄" } from "./emojis.js";
```

It requires `@babel/parser@^7.12.0`. When used with `@babel/plugin-transform-modules-commonjs`, the example above will be transformed as

```js
const emojis = require("./emojis.js");
Object.defineProperty(exports, "__esModule", {
value: true,
});

exports["😄"] = emojis.smile;
```

Note that it is not possible to transpile this syntax to ES2015-style imports and exports. They are supported in other module systems such as amd, systemjs and umd.

## Installation

```sh
npm install --save-dev @babel/plugin-syntax-module-string-names
```

## Usage

### With a configuration file (Recommended)

```json
{
"plugins": ["@babel/plugin-syntax-module-string-names"]
}
```

### Via CLI

```sh
babel --plugins @babel/plugin-syntax-module-string-names script.js
```

### Via Node API

```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/plugin-syntax-module-string-names"],
});
```

0 comments on commit 3b3e7f5

Please sign in to comment.