fix(emotion): use swc_css to minify css string #228
Closed
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.
Use swc_css to minify css string in emotion
Use swc_css to minify css string and remove comments
Reason
There are some old projects using emotion@10, and emotion10 runtime cannot handle comments correctly, emotion babel plugin can remove all comments in the css string so it is fine when using babel.
Benefits:
No need to use regex
Can strip comments like @emotion/babel-plugin
Questions:
I wrap the original css string in a selector to make parser works correct, not sure if swc_css has some API to parse css string like
color: red
instead of.sel { color: red }
.The
should_not_trim_end_space_in_first_item
test failed, it removes the last space, is this OK?