Skip to content

chore: update code-red #8719

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

Merged
merged 5 commits into from
Jun 19, 2023
Merged

Conversation

benmccann
Copy link
Member

@benmccann benmccann commented Jun 10, 2023

changelog: https://github.com/Rich-Harris/code-red/blob/master/CHANGELOG.md#101

This needs to get into Svelte 4 to unblock a new version of vite-plugin-svelte: sveltejs/vite-plugin-svelte#673

The tests are failing. I guess some fixtures probably need to be updated. Is there a guide to that or can anyone give tips on how to do it?

@vercel
Copy link

vercel bot commented Jun 10, 2023

@benmccann is attempting to deploy a commit to the Svelte Team on Vercel.

A member of the Team first needs to authorize it.

@dummdidumm
Copy link
Member

dummdidumm commented Jun 19, 2023

The test error looks like an actual bug in code-red, it can't parse this code:

<script>
	import { writable } from 'svelte/store';

	let value = writable({ foo: 1, bar: 2 });
	$value.foo = $value.foo + $value.bar; // 3
	$value.bar = $value.foo * $value.bar; // 6

	// should resubscribe immediately
	value = writable({ foo: $value.foo + 2, bar: $value.bar - 2 }); // { foo: 5, bar: 4 }

	// should mutate the store value
	$value.baz = $value.foo + $value.bar; // { foo: 5, bar: 4, baz: 9 }

	// should resubscribe immediately
	value = writable({ qux: $value.baz - $value.foo }); // { qux: 4 }

	// making sure instrumentation returns the expression value
	$value = {
		one: writable(
			$value = {
				two: ({ $value } = { $value: { fred: $value.qux } }) // { fred: 4 }
			} // { two: { $value: { fred: 4 } } }
		) // { one: { two: { $value: { fred: 4 } } } }
	};

	const one = $value.one;

	value.update(val => ({ answer: $one.two.$value.fred })); // { answer: 4 }
</script>

{JSON.stringify($value)}

The transformed code according to Rollup looks something like this, which is wrong:

  $value = {
    two: set_store_value(value, { $value } = { $value: { fred: $value.qux } }, // { fred: 4 }$value)\n' 
  },
  // { two: { $value: { fred: 4 } } }$value
)), // { one: { two: { $value: { fred: 4 } } } }'

cc @tanhauhau probably came in through Rich-Harris/code-red#76

@gtm-nayan
Copy link
Contributor

Should be fixed by Rich-Harris/code-red#79

@dummdidumm dummdidumm merged commit 0724261 into sveltejs:version-4 Jun 19, 2023
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.

3 participants