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

refactor(css/parser): new approach #6224

Merged
merged 20 commits into from Oct 22, 2022

Conversation

alexander-akait
Copy link
Collaborator

Description:

New CSS parser approach

BREAKING CHANGE:

No, but AST was improved in some cases

Related issue (if exists):

By spec we should get ComponentValue and parse list of components values, but it is more slow than using tokens, so under the hood our parser uses only token, but if we can't apply required grammar we convert tokens to lost of component values to be align with spec

@alexander-akait alexander-akait changed the title Refactor css parser refactor(css/parser): new approach Oct 21, 2022
@kdy1 kdy1 self-assigned this Oct 21, 2022
@kdy1 kdy1 added this to the Planned milestone Oct 21, 2022
@@ -2,7 +2,7 @@
"type": "Stylesheet",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes expected, because now we output list of component values when we can't parser (as in spec) and now we follow spec

"raw": "color"
}
}
"prelude": {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected too due the reason above (only @media isside qualified rule can be written in this style), here we have:

@media print {
    color: teal;
    main {
        color: orange;
    }
}

So browser see it as:

@media print {
    /* In `[]` it is prelude */
    [color: teal;
    main] {
        color: orange;
    }
}

@alexander-akait
Copy link
Collaborator Author

alexander-akait commented Oct 22, 2022

Tests passed + fix many cases with invalid AST (and invalid span) + more tests (no regressions), WIP on perf

@alexander-akait alexander-akait marked this pull request as ready for review October 22, 2022 02:34
Copy link
Member

@kdy1 kdy1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

swc-bump:

  • swc_css_parser

@kdy1 kdy1 enabled auto-merge (squash) October 22, 2022 03:53
@kdy1 kdy1 disabled auto-merge October 22, 2022 03:54
@kdy1 kdy1 enabled auto-merge (squash) October 22, 2022 03:54
@kdy1 kdy1 disabled auto-merge October 22, 2022 03:54
Copy link
Collaborator

@swc-bot swc-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment generated by auto-rebase script

@kdy1 kdy1 enabled auto-merge (squash) October 22, 2022 03:54
@kdy1 kdy1 merged commit ac619e8 into swc-project:main Oct 22, 2022
@alexander-akait alexander-akait deleted the refactor-css-parser branch October 22, 2022 13:06
@kdy1 kdy1 modified the milestones: Planned, v1.3.11 Oct 26, 2022
@swc-project swc-project locked as resolved and limited conversation to collaborators Nov 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants