Skip to content

chore: transformers #12780

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 88 commits into from
Aug 10, 2024
Merged

chore: transformers #12780

merged 88 commits into from
Aug 10, 2024

Conversation

Rich-Harris
Copy link
Member

@Rich-Harris Rich-Harris commented Aug 10, 2024

While working on #12744 — a prerequisite for #12742 — it became clear that overhauling the way we transform state bindings couldn't wait any longer. The current code really is baffling — convoluted thickets of if statements, and logic scattered all over the place.

This PR introduces a completely new approach, expanding on #12530 and #12697. It adds the concept of ad hoc transformation functions to client transform state, where a transform is an object with a read method and (optionally) assign, mutate and update methods.

In other words we can declare all the logic for (for example) props or legacy reactive imports in one place, rather than having the setup logic over here, the getter logic over there, and the setter logic over in some other place. Distinguishing reassignments and mutations also makes everything much cleaner. (Updates fall back to assignments if no update function is provided.)

Draft because it's not quite finished:

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • Prefix your PR title with feat:, fix:, chore:, or docs:.
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests and linting

  • Run the tests with pnpm test and lint the project with pnpm lint

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.

2 participants