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

[Svelte 5] Regression in JS output - script context module variable declarations before import statements #13135

Closed
xeho91 opened this issue Sep 5, 2024 · 2 comments · Fixed by #13132

Comments

@xeho91
Copy link
Contributor

xeho91 commented Sep 5, 2024

Describe the bug

Hi awesome Svelte maintainers!

There's a regression in JS output. I happen to notice it while upgrading svelte to latest version.
Below is the screenshot from when I was trying to inspect as to why the build isn't working anymore.
image

I'll summarise shortly. Variable declarations inside the <script module> tag in the JS output are above the import declarations. Which is... invalid, right? Right?!

With the help of @JReinhold and his amazingly quick search skills, we've managed to narrow down when this regression happened.

So, latest working version is 5.0.0-next.240

Reading the changelogs, I couldn't figure out which one of PR is the culprit, sorry! 😦

Reproduction

A quick comparison in the JS output:

5.0.0-next.240

5.0.0-next.243

import * as $ from "svelte/internal/client";
import { confetti } from '@neoconfetti/svelte';

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

export default function App($$anchor, $$props) {
	$.push($$props, false);
	$.init();

	var div = root();

	$.append($$anchor, div);
	$.pop();
}
const result = confetti();

import * as $ from "svelte/internal/client";
import { confetti } from '@neoconfetti/svelte';

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

export default function App($$anchor, $$props) {
	$.push($$props, false);
	$.init();

	var div = root();

	$.append($$anchor, div);
	$.pop();
}

Diff overview, because I'm nice (nah, I love Svelte).

```js
+ const result = confetti();
+ 
import * as $ from "svelte/internal/client";
import { confetti } from '@neoconfetti/svelte';

var root = $.template(`<div></div>`);
- const result = confetti();

export default function App($$anchor, $$props) {
	$.push($$props, false);
	$.init();

	var div = root();

	$.append($$anchor, div);
	$.pop();
}

Logs

No response

System Info

next

Severity

blocking an upgrade

@xeho91
Copy link
Contributor Author

xeho91 commented Sep 5, 2024

My search skills needs some improvement... a possible duplicate of: #13081

@7nik
Copy link

7nik commented Sep 5, 2024

yeah, it was fixed in #13082, but the fix wasn't good and was reverted. For now #13132 will fix.

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 a pull request may close this issue.

2 participants