babel-plugin-transform-es2015-unicode-regex breaks regex
See original GitHub issueBug Report
- I would like to work on a fix!
Current behavior
/[^\d\-a-z]/iu.exec("a")
correctly evaluates to null
; however, after applying the babel-plugin-transform-es2015-unicode-regex
the transformed code incorrectly evaluates to [ 'a', index: 0, input: 'a', groups: undefined ]
.
The transformed output is:
/(?:[\0-,\.\/:-`\{-\u017E\u0180-\u2129\u212B-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/i.exec("a");
You can see the input/output with the plugin applied here: https://babeljs.io/repl#?browsers=defaults%2C not ie 11%2C not ie_mob 11&build=&builtIns=false&spec=false&loose=false&code_lz=PQbQegOgJhC0CGsBeBdYBLArgOgKYA9cBjACgCJ4yBKIA&debug=false&forceAllTransforms=false&shippedProposals=false&circleciRepo=&evaluate=false&fileSize=false&timeTravel=false&sourceType=module&lineWrap=true&presets=env%2Creact%2Cstage-2%2Cenv&prettier=false&targets=&version=7.11.6&externalPlugins=babel-plugin-transform-es2015-unicode-regex%406.24.1
Expected behavior
babel-plugin-transform-es2015-unicode-regex
should produce code that evaluates to null
to match the input.
Relates: https://github.com/facebook/create-react-app/issues/9654
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
This is fixed upstream now, running
npm update regexpu-core --depth=2
should bring you up to date.Thanks for taking care of this, @jridgewell!