Ensure proposal-unicode-property-regex runs before transform-unicode-regex#10347
Ensure proposal-unicode-property-regex runs before transform-unicode-regex#10347meowtec wants to merge 2 commits intobabel:masterfrom meowtec:fix-regex-property
Conversation
…regex in preset-env
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/11342/ |
| @@ -0,0 +1 @@ | |||
| expect(/^\p{Unified_Ideograph}+$/u.test('中')).toBe(true); | |||
There was a problem hiding this comment.
Could you check if the /s flag works with unicode property escape?
expect(/\p{Unified_Ideograph}./su.test('中\n')).toBe(true);There was a problem hiding this comment.
It got SyntaxError Expected atom ^\p{Unified_I because transform-dotall-regex runs before proposal-unicode-property-regex.
However, if I moved proposal-unicode-property-regex before transform-dotall-regex, it would get a wrong result. see mathiasbynens/regexpu-core#26
There was a problem hiding this comment.
When proposal-unicode-property-regex is applied before transform-dotall-regex, the . token is transformed to equivalent code points given the default dotAll: false, rendered the subsequent transform-dotall-regex inactive.
Preferably regexpu-core could offer a preserveDot: boolean option so that . token can be consumed by transform-dotall-regex after unicode-property transforms.
Note that we may workaround this by plug in dotAllFlags in proposal-unicode-property-regex,
rewritePattern(node.pattern, node.flags, {
dotAllFlags: node.flags.includes("s")
}/cc @mathiasbynens
…d enable `dotAllFlag` in proposal-unicode-property-regex
|
I would be in favor of creating a single plugin which delegates to regexpu, with options to toggle parsing/transform for the various feature. I will propose it to the team. |
|
FWIW, I'm happy to defer to y'all for making the call on what's best for Babel. I'm open to changes on the regexpu-core side as well, if that would be helpful. |
#10367 also justifies the approach to create a single regexpu plugin since |
base case:
babelrc:
input:
throw with:
input:
output: