[feature] Add stylex.env for compile time constants #1323
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What changed / motivation ?
Partially implements #1358
StyleX already supports
stylex.defineConstsbut this has a few limitations and trade-offs:This PR introduces a new feature called
stylex.env. This is fundamentally a very simple feature that is similar to howprocess.envis already used in many applications. It allows you to configure the stylex babel plugin with constants that are inlined before the stylex compiler runs. It can also contain arbitrary values.The main trade-off here is that since this is something that is part of the babel config, every change to the constants provided will invalidate the entire cache of stylex compilation.
Additional Context
Some basic tests have been included. Will add more tests with more advanced use-cases.
Pre-flight checklist
Contribution Guidelines