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

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

Open
webJose opened this issue Jun 27, 2024 · 0 comments
Open

Comments

@webJose
Copy link

webJose commented Jun 27, 2024

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".

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

No branches or pull requests

1 participant