-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
chore: remove binding.expression
#12530
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
Conversation
🦋 Changeset detectedLatest commit: b445acd The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
binding.expression
binding.expression
and binding.mutation
Marked this ready for review. Right now it probably looks like a step backwards from a certain angle, but this is a first step towards making all this stuff a lot more flexible and robust — I anticipate that the |
binding.expression
and binding.mutation
binding.expression
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
hal-fixing-lightbulb.gif
This started out with #12511. As mentioned in that PR, I'd like to move more of the each block optimisation to compile time, if possible. My first step was to get rid of
$.unwrap(i)
in cases like this......because it's a bit daft to call
$.unwrap
when we know perfectly well thati
is a) not a signal, and b) defined, making the?? ""
pointless. (Also,unwrap
relies on brittle duck typing and should be removed.)But it wasn't that simple, because in some contexts the index might be wrapped in a source, and in others (i.e. the key function) not. Which made me happy because there's a part of our codebase that I've wanted to get rid of for a long time, and I finally have a good reason:
binding.expression
.Essentially, we assign an
expression
to certain bindings when we have specific transformation requirements. But it's not really in keeping with how the rest of the compiler works — ideally, transformation would be pure, and all the mutatey stuff would happen during the analysis phase. (Imagine a world in which it's possible to generate server and client output from a single compiler run, rather than the current — wasteful — process of parsing and analysing from scratch before handing the result off to the transformation phase. While that's not a near term goal, reducing the number of places where mutation can happen in order to make code more understandable and robust is always a goal.)And we have a perfectly good mechanism already —
context.state
. This PR adds agetters
record toTransformState
that allows nodes to create those ad hoc overrides without mutating the bindings themselves. This should make it much easier to fix thei
thing above, and no doubt other things too.Right now it only uses
getters
in one place, hence draft status.needs to have an equivalentwill do this in a follow-upsetters
record to replacebinding.mutation
Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.Tests and linting
pnpm test
and lint the project withpnpm lint