refactor(transformer-attributify-jsx)!: use babel plugin instead of regex plugin #4807
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.
Description
transformer-attributify-jsx using regex to transform by default. but regex has many bugs and performance issue.
#4384 #4195
Performance
#3088
Since in unocss's vscode plugin, the regex version of
transformer-attributify-jsxwould be running many times when user is typing. So i useprocess.env.VSCODE_CWDto prevent it running in vscode plugin. it should only used in runtime plugin.After resolve the performance issue, we can safely use the babel plugin.
Babel plugin
Before the babel plugin was walked ast twice. so i use
@babel/traversewalk the ast once, make it faster.