Skip to content

Conversation

deathaxe
Copy link
Collaborator

@deathaxe deathaxe commented Jun 25, 2025

Resolves #4220

This PR...

  1. introduces JavaScript (Plain), TypeScript (Plain), JSX (Plain) and TSX (Plain) without syntax highlighted template strings as possible base syntax for template languages which don't need them or would fail loading due to complexity otherwise.

  2. replaces embed directives by set and includes all syntaxes used for highlighting template strings, to prevent them being prematurely terminated by interpolations with nested template strings.

  3. Nested template strings don't highlight any syntax to keep syntax cache size in sane limits.

Note:

Compiled syntax cache of each language grows from about 170kB to 1.2MB also causing all template languages which make use of it to grow. I didn't hit any limits yet and Python is also 2.5MB now with new SQL syntax being included a couple of times. The overall size of all compiled languages together grows from 4.2MB to 5.4MB, only. So maybe it is safe enough for production.

This commit...

1. introduces JavaScript (Plain) and TypeScript (Plain) without syntax
   highlighting in tagged template strings.

2. replaces `embed` directives by `set` and include all syntaxes used for
   highlighting tagged template strings, to prevent nested interpolations
   with template strings prematurely terminate the outer template string.

3. Nested template strings don't highlight any syntax to keep syntax cache
   size in sane limits.

4. JSX and TSX use "Plain" syntax without syntax highlighted template strings.
   Attempting to base them onto normal JS and TS raises errors about not all
   base syntaxes using same base.
@TerminalFi
Copy link
Contributor

I wouldn’t say it only goes from 4.2 to 5.4. That’s 25% or so increase in size. Relatively large

@deathaxe
Copy link
Collaborator Author

deathaxe commented Jun 27, 2025

Not limiting to "plain" syntaxes in nested templates it would go from 4.2 to 12MB, which the "only" was compared with.

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

Successfully merging this pull request may close these issues.

[JavaScript] Template string inside tag function breaks syntax highlighting
3 participants