parcel-bundler / lightningcss

An extremely fast CSS parser, transformer, bundler, and minifier written in Rust.
https://lightningcss.dev
Mozilla Public License 2.0
6.55k stars 190 forks source link

Incorrect error message for `@layer` between `@import`s #803

Open sapphi-red opened 3 months ago

sapphi-red commented 3 months ago

The following CSS is invalid as the @import is not consecutive.

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+KR:wght@100;200;300;400;500;600;700&display=swap');

@layer reset, base, variant, state, component;

@import url(./tester.css) layer(base);

Reproduction

If this CSS is input, lightningcss errors with the following message:

@import rules must precede all rules aside from @charset and @layer statements

This message is true, but doesn't apply to this input. @import does precede all other statements aside from @layer. In this case, I think the error message needs to be something like "@import must be consecutive".