-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Migrate bare values to named values #18000
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
This in theory can convert bare values to named values _if_ there exists a replacement. This is the minimal amount of work required to make that happen. But this also means that there is additional unnecessary work involved, such as: 1. Canonicalizing the value — we bare values don't even include whitespace-like characters so this is unnecessary work. 2. If we can't find a replacement using a named value, we will try arbitrary values... but it's already an arbitrary value. Will tackle these in the next few commits.
This will allow us to reuse them later in other migrations, once we split the arbitrary-utilities migration to also handle the bare value to named value migration.
This is now moved to its own dedicated migration file
? `${designSystem.theme.prefix}:${input}` | ||
: input, | ||
) | ||
} |
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.
Don't we have exactly this implementation of parseCandidate in some other migration? I feel like I've seen this before.
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.
Ah yeah, I copied this whole file and deleted what I didn't need. Can move this to the candidates.ts
file but should we just call it parseCandidate
or something like prefixAwareParseCandidate`
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.
Just parseCandidate
is fine for now. Can improve the name if we feel it's necessary later.
This PR improves the upgrade tool by also migrating bare values to named values defined in the
@theme
. It's similar to the existing migration we already had, but specialized for just bare values. This makes it a bit faster as well because we don't have to try and replace a bare value with a bare value.Recently we shipped some updates dat allowed us to migrate arbitrary values (with square brackets), but we didn't migrate bare values yet.
That means that in this example:
We migrated this to:
With this change, we will also try and migrate the bare value to a named value. So this example:
Now becomes:
Test plan
Before:

After:
