-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create plugin-transform-unicode-escapes.md
- Loading branch information
1 parent
839197a
commit dff9324
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
--- | ||
id: babel-plugin-transform-unicode-escapes | ||
title: @babel/plugin-transform-unicode-escapes | ||
sidebar_label: transform-unicode-escapes | ||
--- | ||
|
||
Compile ES2015 Unicode escapes to ES5 | ||
|
||
> **NOTE**: This plugin is included in `@babel/preset-env` | ||
## Example | ||
|
||
**In** | ||
|
||
```javascript | ||
var \u{1d49c} = "\u{Babe1}"; | ||
|
||
console.log(\u{1d49c}); | ||
``` | ||
|
||
**Out** | ||
|
||
```javascript | ||
var _ud835_udc9c = "\uDAAA\uDFE1"; | ||
|
||
console.log(_ud835_udc9c); | ||
``` | ||
|
||
## Installation | ||
|
||
```sh | ||
npm install --save-dev @babel/plugin-transform-unicode-escapes | ||
``` | ||
|
||
## Usage | ||
|
||
### With a configuration file (Recommended) | ||
|
||
```json | ||
{ | ||
"plugins": ["@babel/plugin-transform-unicode-escapes"] | ||
} | ||
``` | ||
|
||
### Via CLI | ||
|
||
```sh | ||
babel --plugins @babel/plugin-transform-unicode-escapes | ||
``` | ||
|
||
### Via Node API | ||
|
||
```javascript | ||
require("@babel/core").transform("code", { | ||
plugins: ["@babel/plugin-transform-unicode-escapes"] | ||
}); | ||
``` |