feat: add fallback for util.styleText on Node <20.12.0 #2606
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.


Adds a safe fallback for
util.styleTexton Node.js versions earlier than 20.12.0, where the API is not yet available.When
util.styleTextis missing, the fallback simply returns the unmodified text. This prevents runtime errors and maintains compatibility across environments running different Node versions.Motivation
util.styleTextwas introduced in Node 20.12.0. Many users and CI systems still run older Node versions, which can cause reference errors if the function is used directly. This change ensures graceful degradation without affecting newer environments.Changes
util.styleText.Example
Issues
Closes #2574
Summary by cubic
Adds a fallback for util.styleText on Node <20.12.0 to prevent runtime errors and keep console output working across environments. The fallback returns plain text and is provided via a small helper now used by preview-server and react-email instead of importing from node:util.