breaking: decouple parser switch and transformer switch#30
Merged
nicolo-ribaudo merged 2 commits intomathiasbynens:masterfrom Sep 20, 2019
Merged
Conversation
nicolo-ribaudo
approved these changes
Sep 15, 2019
Collaborator
nicolo-ribaudo
left a comment
There was a problem hiding this comment.
I wouldn't classify this PR a breakinc change, since it just prevents regexpu from throwing a bunch of exceptions.
Collaborator
Author
|
I have reverted |
Collaborator
|
So now some parser features are enabled by default and some aren't? I don't think that this inconsistency is good. |
Collaborator
Author
|
If we enable In babel/babel#10447 we have enabled |
1 task
mathiasbynens
approved these changes
Sep 18, 2019
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In this PR we decouple the regjsparser switch from the regexpu-core transformer switch. It is a breaking change since it does not throw for
\\p{Unified_Ideograph}whenunicodePropertyEscapeis not enabled, instead it assumes our user know exactly what she is doing and only transform the features as instructed.By doing this,
babel-preset-envcan have more granular control on ES6+ regex features. For example, when user specifies{ "target": "Hypothetical browser supports unicode property escape but not named capturing groups" }and let's say the pattern we want to transform is
/(?<name>\p{Unified_Ideograph}{3})/uwe don't have to transform unicode property escape here and instead should only passnamedGroup: true.However, to transform this pattern, we still need regjsparser support for unicode property escape otherwise the parser will throw on
\p{. Therefore, we maximize the parser support, allow parser to parse any new syntax, and only transform when user opt-in the transformation. By doing so we encourage to ship native browser features without superfluous transformations.Edits: the previous
Safari 12example above is practically invalid as of Sep 2019. Every browser supports unicode property escape also support named capturing groups.