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

Handle bad CSS better #515

Merged
merged 3 commits into from
Sep 8, 2022
Merged

Handle bad CSS better #515

merged 3 commits into from
Sep 8, 2022

Conversation

matthewp
Copy link
Contributor

@matthewp matthewp commented Sep 7, 2022

Changes

  • Currently the compiler expects preprocessStyle to return valid CSS. However if there is an error preprocessing it might now.
  • This makes it so that preprocessStyle can return an error. The compiler uses that to know the CSS is bad.
  • The styleError is returned in the transform result and the caller can use that error to do whatever it needs.
  • Part of Astro hangs on invalid scss astro#4615, still need core update to completely fix.

Testing

Test added

Docs

N/A

@changeset-bot
Copy link

changeset-bot bot commented Sep 7, 2022

🦋 Changeset detected

Latest commit: c953187

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@astrojs/compiler Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Member

@natemoo-re natemoo-re left a comment

Choose a reason for hiding this comment

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

LGTM! Not sure what would happen with one-to-many styles, but if you're not worried about that, this is a good enough solution for now.

@matthewp
Copy link
Contributor Author

matthewp commented Sep 8, 2022

That's a good point! Current in the Vite plugin we only handle the case where there's one style error. Let me see if I can improve on that here.

@matthewp
Copy link
Contributor Author

matthewp commented Sep 8, 2022

Ok, I made it return an error of style errors instead.

@matthewp matthewp merged commit 6ebcb4f into main Sep 8, 2022
@matthewp matthewp deleted the throw-on-bad-css branch September 8, 2022 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants