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] Ensure strict mode for EnvironmentConfigSchema in order to throw an error for unallowed config properties #31448

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Ganbin
Copy link

@Ganbin Ganbin commented Nov 7, 2024

Summary

Enable strict mode for EnvironmentConfigSchema to enforce validation and throw errors for unrecognized configuration properties. This change will help identify typos or incorrect property names in the compiler configuration, making it easier to catch and correct mistakes during setup.

How did you test this change?

I verified this change within my project, confirming that errors are displayed when incorrect properties are passed to the ReactCompilerConfig object. Additionally, I created a test file at compiler/packages/babel-plugin-react-compiler/src/__tests__/EnvironmentConfigSchema-test.ts. However, I encountered issues running tests within the compiler/packages/babel-plugin-react-compiler package, even without my changes, despite setting up my environment correctly. While I have added the test file, I could use guidance on resolving this testing issue.
Edit: the tests are now ok

Potential break

This change could disrupt some environments if the configuration contains disallowed properties, as previously these would have simply been ignored. With the new strict() rule, the configuration object is now restricted to only contain allowed properties. If any properties are removed in the future, developers will need to ensure they are also removed from the configuration to avoid errors. In my opinion, this approach is beneficial, as it explicitly flags incorrect properties and encourages developers to maintain a correct configuration object.
As the compiler is still in beta, I think it is better to add the strict() now than later.

Copy link

vercel bot commented Nov 7, 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 7, 2024 9:08pm

@facebook-github-bot
Copy link

Hi @Ganbin!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@poteto
Copy link
Member

poteto commented Nov 7, 2024

Seems reasonable, could you fix the tests? Thanks!

@Ganbin
Copy link
Author

Ganbin commented Nov 7, 2024

I have fixed the tests and added a Potential break section in the PR description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants