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

Feature request: friendlier error for empty bracket pair in template instead of full js_parse_error being thrown. #1069

Open
UltraCakeBakery opened this issue Jan 16, 2025 · 9 comments

Comments

@UltraCakeBakery
Copy link

Describe the problem

When working in large svelte components in svelte kit, the console is flooded with the entire components json representation when a is_parse error is thrown by the compiler caused by a simple empty bracket pair:

https://svelte.dev/playground/0a51fe6115b34b4a80268714337994b5?version=5.18.0

look at the size / position of my scrollbar:

Image

Describe the proposed solution

A custom error for this edge case, just saying "empty brackets not allowed in template.", or have it just strip it during compilation instead of throwing.

Importance

would make my life easier

@paoloricciuti
Copy link
Member

Throwing a different error would not help. The error would still be thrown in the same way by vite-plugin-svelte...i'm gonna transfer this issue to the other repo in case @dominikg has better ideas but i think at the same time having the plugin code could be very useful when debugging some error that could be introduced by preprocessors or other plugins.

@dummdidumm
Copy link
Member

I don't think we should change anything here

@paoloricciuti
Copy link
Member

I don't think we should change anything here

Agreed...the only thing i could see feasible is maybe an option for vite-plugin svelte

Also i can't transfer it there 😄

@dummdidumm
Copy link
Member

I'm gonna go ahead and close this - yes it's a big error but it's very detailed, and forgetting content in your braces does not happen that often

@dummdidumm dummdidumm closed this as not planned Won't fix, can't repro, duplicate, stale Jan 16, 2025
@UltraCakeBakery
Copy link
Author

I would not have made this issue if it didn't happen that often.

But ok.

@dominikg
Copy link
Member

dominikg commented Jan 16, 2025

hmm, vite plugin svelte should format the frame and message more nicely on the console.

sveltelab repro: https://www.sveltelab.dev/o2e6wq4d900igtk

did something change with CompileError recently?

@UltraCakeBakery
Copy link
Author

hmm, vite plugin svelte should format the frame and message more nicely on the console.

sveltelab repro: https://www.sveltelab.dev/o2e6wq4d900igtk

did something change with CompileError recently?

This has been a thing for months. Maybe the example I provided has changed recently, but I have been seeing this happen for a while now.

@dominikg dominikg transferred this issue from sveltejs/svelte Jan 16, 2025
@dominikg dominikg reopened this Jan 16, 2025
@dominikg
Copy link
Member

lets see if we can make the terminal output nicer again. It's correct that the svelte error contains the full information but we shouldn't put json on the console like that

@UltraCakeBakery
Copy link
Author

Thanks for looking into 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

4 participants