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

[compiler][ez] Clean up pragma parsing for tests + playground #31347

Merged
merged 1 commit into from
Nov 5, 2024
Merged

Conversation

mofeiZ
Copy link
Contributor

@mofeiZ mofeiZ commented Oct 24, 2024

Move environment config parsing for inlineJsxTransform, lowerContextAccess, and some dev-only options out of snap (test fixture). These should now be available for playground via @inlineJsxTransform and lowerContextAccess.

Other small change:
Changed zod fields from nullish() -> nullable().default(null). nullish fields accept null | undefined and default to undefined. We don't distinguish between null and undefined for any of these options, so let's only accept null + default to null. This also makes EnvironmentConfig in the playground more accurate. Previously, some fields just didn't show up as prettyFormat({field: undefined}) does not print field.

See playground:
Before (note environment options missing)
image

After (note environment options not missing)
image

@inlineJsxTransform and a few others now also work
image

Copy link

vercel bot commented Oct 24, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 5, 2024 11:14pm


/**
* For snap test fixtures and playground only.
*/
export function parseConfigPragma(pragma: string): EnvironmentConfig {
Copy link
Contributor

Choose a reason for hiding this comment

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

Before this just used environment defaults, now we're explicitly adding in dummy values just for tests/playground. Let's rename? parseConfigPragmaForTests() or similar

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

Move environment config parsing for `inlineJsxTransform`, `lowerContextAccess`, and some dev-only options out of snap (test fixture). These should now be available for playground via `@inlineJsxTransform` and `lowerContextAccess`.

Other small change:
Changed zod fields from `nullish()` -> `nullable().default(null)`. [`nullish`](https://zod.dev/?id=nullish) fields accept `null | undefined` and default to `undefined`. We don't distinguish between null and undefined for any of these options, so let's only accept null + default to null. This also makes EnvironmentConfig in the playground more accurate. Previously, some fields just didn't show up as `prettyFormat({field: undefined})` does not print `field`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants