svelte: Svelte 5: Forward compatibility break caused by #11954

Describe the bug

[!NOTE] I know there are “hundred” ways to get around and fix the issue or improve the writeup, so PLEASE don’t tell me how I should write code.

But please take into account that I spend hours locating the issue due to the commonness of the original class name, and that I’ve already fixed the code in my own project. I spent extra time making a minimal reproduction as well as reporting the issue.

The issue is reported because it causes forward compatibility breakage and others may encounter the same error.

The issue has been located and confirmed to be caused by #11954.

So the versions with the issue are: svelte@5.0.0-next.152 ~ svelte@5.0.0-next.192

In earlier versions as well as svelte@4, the same code does not cause the issue.

The issue only occurs during vite build and not dev.

Reproduction

StackBlitz-Svelte-5.0.0-next.192

<script>
	let color;
</script>

<div class="abc {color || 'red'}"></div>

Logs

vite v5.3.4 building for production...
✓ 80 modules transformed.
x Build failed in 580ms
error during build:
[vite:esbuild-transpile] Transform failed with 1 error:
assets/index-!~{001}~.js:1434:51: ERROR: Expected ")" but found "}"

Expected ")" but found "}"
1432|   var div = root();
1433|  
1434|   template_effect(() => set_class(div, `abc ${('red'}`));
    |                                                     ^
1435|   append($$anchor, div);
1436|  }

    at failureErrorWithLog (/home/projects/vitejs-vite-eaupzs/node_modules/esbuild/lib/main.js:1462:15)
    at start/< (/home/projects/vitejs-vite-eaupzs/node_modules/esbuild/lib/main.js:745:50)
    at sendRequest/responseCallbacks[id] (/home/projects/vitejs-vite-eaupzs/node_modules/esbuild/lib/main.js:612:17)
    at handleIncomingPacket (/home/projects/vitejs-vite-eaupzs/node_modules/esbuild/lib/main.js:667:20)
    at readFromStdout (/home/projects/vitejs-vite-eaupzs/node_modules/esbuild/lib/main.js:590:27)
    at emit (node:events:30:10899)
    at addChunk (node:internal/streams/readable:225:3685)
    at readableAddChunk (node:internal/streams/readable:225:3393)
    at internal/streams/readable/Readable.prototype.push (node:internal/streams/readable:225:4971)
    at onStreamRead (node:internal/stream_base_commons:211:2596)
    at _0x5a72d5/< (https://vitejsviteeaupzs-c4v3.w-corp-staticblitz.com/blitz.41692973.js:40:515096)
    at _0x14e07c/< (https://vitejsviteeaupzs-c4v3.w-corp-staticblitz.com/blitz.41692973.js:40:517084)
    at _0x19b239/< (https://vitejsviteeaupzs-c4v3.w-corp-staticblitz.com/blitz.41692973.js:40:195382)
    at _0x3eacb0 (https://vitejsviteeaupzs-c4v3.w-corp-staticblitz.com/blitz.41692973.js:40:195487)
    at _0x14e07c (https://vitejsviteeaupzs-c4v3.w-corp-staticblitz.com/blitz.41692973.js:40:516979)
    at _0x1fa6c6 (https://vitejsviteeaupzs-c4v3.w-corp-staticblitz.com/blitz.41692973.js:40:513649)
    at _0x8b8b7a/< (https://vitejsviteeaupzs-c4v3.w-corp-staticblitz.com/blitz.41692973.js:40:517356)
    at _0x8b8b7a (https://vitejsviteeaupzs-c4v3.w-corp-staticblitz.com/blitz.41692973.js:40:517334)
    at _0x2d466d (https://vitejsviteeaupzs-c4v3.w-corp-staticblitz.com/blitz.41692973.js:40:516307)

System Info

svelte@5.0.0-next.152

Severity

annoyance

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 19 (11 by maintainers)

Most upvoted comments

Why don’t you go and try it yourself? See if I’m right?

I don’t have to respond to your questions when you don’t say “please” and question my work.

And I really don’t need your help,

I’m not joking, what do you think I wrote the big NOTE at the beginning for?

Sorry for off-topic but honestly this behavior should be noted. This is ridiculously aggressive for no reason. Accepting collaborators to get talked to like that is detrimental to the project and should not be accepted.

What should I try? I’m asking what process did you use to pinpoint that PR because that could help better understand what the actual issue is.

@paoloricciuti

I don’t have to respond to your questions when you don’t say “please” and question my work.

The issue and reproduction is there for you to check and verify on your own, or you can ignore and close the issue like other.

I wonder if it’s an upstream problem about how the code gets tree shaken. How can you pinpoint the PR? Just because it was the only change in that version?

@paoloricciuti Why don’t you go and try it yourself? See if I’m right?

Where did I question your work?

How can you pinpoint the PR? Just because it was the only change in that version?

@paoloricciuti The following quotes GPT’s analysis:

Yes, the statement does contain a tone of doubt. The phrase “Just because it was the only change in that version?” questions the validity of pinpointing the PR based solely on it being the only change in that version.

I really don’t get why you are always so oppositive against people trying to help you.

And I really don’t need your help, I wrote very clearly that I have solved my problem and that I am providing feedback to help the project.

And if you really need help finding the answer to that question, here is an ECE video to help you.

Where did I question your work?

How can you pinpoint the PR? Just because it was the only change in that version?

@paoloricciuti The following quotes GPT’s analysis:

Yes, the statement does contain a tone of doubt. The phrase “Just because it was the only change in that version?” questions the validity of pinpointing the PR based solely on it being the only change in that version.

I really don’t get why you are always so oppositive against people trying to help you.

And I really don’t need your help, I wrote very clearly that I have solved my problem and that I am providing feedback to help the project.

And if you really need help finding the answer to that question, here is an ECE video to help you.

Ok I’m done with you. I’m here for the same reason, to help the project and what I get back from you from my free time that I spend helping the project is just bitterness because you think I’m questioning your work while I was just trying to understand what you did.

You are heavily biased against me evidently so I will not interact with you anymore.

Never blocked anyone on any platform but I will make an exception this time. See you.

Where did I question your work?

How can you pinpoint the PR? Just because it was the only change in that version?

@paoloricciuti The following quotes GPT’s analysis:

Yes, the statement does contain a tone of doubt. The phrase “Just because it was the only change in that version?” questions the validity of pinpointing the PR based solely on it being the only change in that version.

Well if GPT says so lol

Joking aside it was an attempt to allow you to just answer “yes” if that was the case. Since it’s not the case the question is still the same and it would help me understand the issue. So if we can please avoid being defensive my question was genuine. How can you pinpoint the PR? I’m not questioning your work, just trying to understand if you have additional information that can help me understand where the issue originate from.

I want to avoid start researching eventual problems in the vite plugin if you already know that the issue is in that pr.

What should I try? I’m asking what process did you use to pinpoint that PR because that could help better understand what the actual issue is.

@paoloricciuti

I don’t have to respond to your questions when you don’t say “please” and question my work.

The issue and reproduction is there for you to check and verify on your own, or you can ignore and close the issue like other.

Where did I question your work? I really don’t get why you are always so oppositive against people trying to help you. To be clear I see the issue as well and in a sveltekit project too so there’s definitely a problem here. However the compiled code from svelte seems correct and different from what’s shown in the frame of the compilation error.

So my thinking is that this is an issue in plugin-vite-svelte or maybe even higher up in esbuild-transpile. But I could be wrong so I wanted more information about how you pinpointed the PR because if you are sure that that pr introduced the bug maybe you have more info about the problem.

How can you pinpoint the PR? Just because it was the only change in that version?

@paoloricciuti Why don’t you go and try it yourself? See if I’m right?

What should I try? I’m asking what process did you use to pinpoint that PR because that could help better understand what the actual issue is.

Mmm this is weird…the code compiled from svelte looks correct to me

import * as $ from "svelte/internal/client";

var root = $.template(`<div></div>`);

export default function App($$anchor) {
	let color;
	var div = root();

	$.set_class(div, `abc ${(color || 'red') ?? ""}`);
	$.append($$anchor, div);
}

I wonder if it’s an upstream problem about how the code gets tree shaken. How can you pinpoint the PR? Just because it was the only change in that version?