Skip to content

smarter compiler output for string literals in expressions #10145

@Rich-Harris

Description

@Rich-Harris

Describe the problem

In rare cases you might need to put a string literal inside curlies, e.g. to represent a { character itself (yes, you can do it with HTML entities but {'{'} is easier) or for finer control over whitespace:

https://svelte-5-preview.vercel.app/#H4sIAAAAAAAAEyWMsQ6EIBBEf4XsFduQXE9336EWqIuSKBBYLzk3_PtBrGbeS2YEnD-ogBkEgj0JDHxSAg38Sx3Klw6mxiVeeelGXmSXXQ3oYkStcLb5iRsnZYvi3YetjmFkeaoWVNiEvPuwtq8zrt55WsFwvqhO9Q8H_VvBhgAAAA==

This results in unnecessarily complicated output.

Describe the proposed solution

-$.text_effect(node_1, () => `${$.stringify($.unwrap(thing))},${$.stringify(' ')}`);
+$.text_effect(node_1, () => `${$.stringify($.unwrap(thing))}, `);

Alternatives considered

N/A

Importance

nice to have

Metadata

Metadata

Assignees

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