Skip to content

Check the validity of the generated CSS #224

Open
@Mad-Kat

Description

At the moment we don't perform any checks inside next-yak if the generated CSS is valid CSS. Until now we relied on the capabilities of Lightning CSS or PostCSS within next.js that do some form of validation.

However we noticed that certain cases like this:

import { styled } from "next-yak";

const MyDiv = styled.div`
  &:nth-child(${() => 2}) {
    color: red;
  }
`;

produce an incorrect CSS:

import { styled } from "next-yak/internal";
import __styleYak from "./index.yak.module.css!=!./index?./index.yak.module.css";
const MyDiv = /*YAK Extracted CSS:
.MyDiv {
  &:nth-child(var(--yrRH4Ik)) {
    color: red;
  }
}
*/ /*#__PURE__*/ styled.div(__styleYak.MyDiv, {
    "style": {
        "--yrRH4Ik": ()=>2
    }
});

that isn't flagged by PostCSS but is flagged by Lightning CSS as invalid CSS.

To improve the error messages and to have a consistent feel (independent if you use Lightning CSS or PostCSS) we should add a validation step after we've generated the CSS within the comments.

What do you think?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions