Skip to content

Improve message for error "Nesting selectors can only be used inside a rule" #12208

@webJose

Description

@webJose

Describe the problem

The problem is the current state of the error. I just started a Svelte v5 branch for a large component library. I installed Svelte v5 and compiled. The error that I get is this:

CompileError: Nesting selectors can only be used inside a rule
    at e (file:///C:/Users/jpramire/src/repos/construction.svelte-dlux/node_modules/svelte/src/compiler/errors.js:62:8)
    at Module.css_nesting_selector_invalid_placement (file:///C:/Users/jpramire/src/repos/construction.svelte-dlux/node_modules/svelte/src/compiler/errors.js:521:2)
    at NestingSelector (file:///C:/Users/jpramire/src/repos/construction.svelte-dlux/node_modules/svelte/src/compiler/phases/2-analyze/css/css-analyze.js:183:6)
    at go (file:///C:/Users/jpramire/src/repos/construction.svelte-dlux/node_modules/svelte/src/compiler/phases/visitors.js:49:5)
    at visitor (file:///C:/Users/jpramire/src/repos/construction.svelte-dlux/node_modules/svelte/src/compiler/phases/visitors.js:64:4)
    at visit (file:///C:/Users/jpramire/src/repos/construction.svelte-dlux/node_modules/zimmerframe/src/walk.js:121:13)
    at file:///C:/Users/jpramire/src/repos/construction.svelte-dlux/node_modules/zimmerframe/src/walk.js:52:25
    at Array.forEach (<anonymous>)
    at Object.next (file:///C:/Users/jpramire/src/repos/construction.svelte-dlux/node_modules/zimmerframe/src/walk.js:50:19)
    at go (file:///C:/Users/jpramire/src/repos/construction.svelte-dlux/node_modules/svelte/src/compiler/phases/visitors.js:45:29)

And what's the problem? That it doesn't say which file is the one with the problem. The stack trace doesn't contain it because logically, the file is not being executed. It is therefore a needed piece of information in the error message.

Describe the proposed solution

Include the problematic file in the error message:

Nesting selectors can only be used inside a rule in file "xxxx.svelte".

Importance

would make my life easier

UPDATE

Since I have dozens of files and zero clue about the one error'ing out, I'm very tempted to say that I the importance of this could be upgrated to "cannot use Svelte without this".

Metadata

Metadata

Assignees

No one assigned

    Labels

    awaiting submitterneeds a reproduction, or clarification

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions