-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Description
Bug Report
Current Behavior
Adding the u flag to a regexp with a named capturing group causes babel to crash if any transform related to unicode regexps is also enabled. This happens even when the named capturing group transform is enabled in preset-env, likely due to plugin execution order.
Input Code
void /(?<test>foo)/uExpected behavior/code
void _wrapRegExp(/(foo)/, {
test: 1
})Babel Configuration (.babelrc, package.json, cli command)
{
"presets": [
"env"
]
}Environment
- Babel version(s): 7.4.3
- Node/npm version: 12.6.0
- OS: macOS 10.14
- Monorepo: yes
- How you are using Babel: loader
Possible Solution
The named capturing group transform could run before the other transforms; or regexpu should get support for parsing and preserving named capturing groups
Additional context/Screenshots
While writing a reproduction to this I also found an emit bug when babel helpers are injected and the first statement is a regexp literal. Not related, just a coincidence.