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

chore: unified expression metadata #12644

Merged
merged 11 commits into from
Jul 29, 2024
Merged

Conversation

Rich-Harris
Copy link
Member

Another step towards the more comprehensive compile-time analysis of each block dependencies that will unblock #12511.

Currently, various nodes need to know whether the expressions they contain are dynamic (i.e. reference state, or could reference state) and/or contain call expressions (which may mean they need to be wrapped in a derived, or a separate effect or whatever). This happens in a slightly ad hoc and messy fashion.

This PR neatens it up, and also adds a dependencies set to each expression metadata object, which should soon enable more detailed analysis. The goal is to be able to optimise cases like this...

{#each [1, 2, 3] as n}...{/each}

...where it's frivolous to wrap the array members in signals.

There is a blocker to doing that currently: we would need to call context.visit(node.expression, ...) inside the EachBlock visitor. That's not possible, because the analysis-phase visitor merging prevents us from calling context.visit. I've been pissed off at this for a long time, and this is the straw that broke the camel's back — it's time to overhaul the analysis phase and have a single visitor per node type. Going to work on that as soon as this is merged.

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

Copy link

changeset-bot bot commented Jul 29, 2024

⚠️ No Changeset found

Latest commit: d796df1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Member

@dummdidumm dummdidumm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two small things, otherwise 👍

@Rich-Harris Rich-Harris merged commit 65234b8 into main Jul 29, 2024
7 of 9 checks passed
@Rich-Harris Rich-Harris deleted the unified-reactivity-metadata branch July 29, 2024 13:57
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