Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swc v1.3.102 minify broke antd theme #8475

Closed
nuintun opened this issue Jan 2, 2024 · 5 comments · Fixed by #8518
Closed

swc v1.3.102 minify broke antd theme #8475

nuintun opened this issue Jan 2, 2024 · 5 comments · Fixed by #8518
Assignees
Labels
Milestone

Comments

@nuintun
Copy link
Contributor

nuintun commented Jan 2, 2024

Describe the bug

Minify code with swc.

ant-design/ant-design#46719

image

Input code

No response

Config

No response

Playground link (or link to the minimal reproduction)

ant-design/ant-design#46719

SWC Info output

No response

Expected behavior

Fix code minify.

Actual behavior

No response

Version

1.3.102

Additional context

No response

@nuintun nuintun added the C-bug label Jan 2, 2024
@kdy1 kdy1 added this to the Planned milestone Jan 2, 2024
@kdy1 kdy1 self-assigned this Jan 2, 2024
@kdy1
Copy link
Member

kdy1 commented Jan 2, 2024

@nuintun Is v1.3.102 the first version that breaks antd theme?

@nuintun
Copy link
Contributor Author

nuintun commented Jan 2, 2024

@kdy1 I tested and found that it started from v1.3.99.

PS: v1.3.96 is good, v1.3.97- v1.3.98 have been unpublished, so I did not test it.

@MadCcc
Copy link

MadCcc commented Jan 2, 2024

The main cause is swc bundle differs between es5 and es6.

@ctrl/tinycolor targets es2021 in 4.x, which makes the artifacts differ:

// 4.x
const CSS_INTEGER = '[-\\+]?\\d+%?';
const CSS_NUMBER = '[-\\+]?\\d*\\.\\d+%?';
const CSS_UNIT = `(?:${CSS_NUMBER})\|(?:${CSS_INTEGER})`;

// 3.x
var CSS_INTEGER = '[-\\+]?\\d+%?';
var CSS_NUMBER = '[-\\+]?\\d*\\.\\d+%?';
var CSS_UNIT = "(?:".concat(CSS_NUMBER, ")\|(?:").concat(CSS_INTEGER, ")");

And when swc bundle template string, the result will be escaped one more time, [-\\+] will become [-\\\\+], which is broken.

kdy1 added a commit that referenced this issue Jan 19, 2024
**Related issue:**

 - Closes #8475
 - #8496 (Fixed by #8510)
@kdy1 kdy1 modified the milestones: Planned, v1.3.105 Jan 21, 2024
@swc-bot
Copy link
Collaborator

swc-bot commented Feb 20, 2024

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@swc-project swc-project locked as resolved and limited conversation to collaborators Feb 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging a pull request may close this issue.

4 participants