Default unicode-property-regex to outputting 'u' flag regexes.

This commit is contained in:
Logan Smyth 2017-11-06 18:35:02 -08:00
parent e7c57ae85a
commit 3782c7267e
3 changed files with 12 additions and 3 deletions

View File

@ -43,11 +43,18 @@ To transpile to ES6/ES2015:
```js ```js
require("@babel/core").transform(code, { require("@babel/core").transform(code, {
"plugins": [ "plugins": [
["@babel/proposal-unicode-property-regex", { "useUnicodeFlag": true }] ["@babel/proposal-unicode-property-regex", { "useUnicodeFlag": false }]
] ]
}); });
``` ```
## Options
* `useUnicodeFlag` (defaults to `true`)
When disabled with `false`, the transform will convert unicode regexes to
non-unicode regexes, removing the `u` flag. See https://www.npmjs.com/package/regexpu-core#useunicodeflag-default-false- for more information.
## Author ## Author
| [![twitter/mathias](https://gravatar.com/avatar/24e08a9ea84deb17ae121074d0f17125?s=70)](https://twitter.com/mathias "Follow @mathias on Twitter") | | [![twitter/mathias](https://gravatar.com/avatar/24e08a9ea84deb17ae121074d0f17125?s=70)](https://twitter.com/mathias "Follow @mathias on Twitter") |

View File

@ -2,7 +2,7 @@ import rewritePattern from "regexpu-core";
import * as regex from "@babel/helper-regex"; import * as regex from "@babel/helper-regex";
export default function(api, options) { export default function(api, options) {
const { useUnicodeFlag = false } = options; const { useUnicodeFlag = true } = options;
if (typeof useUnicodeFlag !== "boolean") { if (typeof useUnicodeFlag !== "boolean") {
throw new Error(".useUnicodeFlag must be a boolean, or undefined"); throw new Error(".useUnicodeFlag must be a boolean, or undefined");
} }

View File

@ -1,5 +1,7 @@
{ {
"plugins": [ "plugins": [
["proposal-unicode-property-regex"] ["proposal-unicode-property-regex", {
"useUnicodeFlag": false
}]
] ]
} }