Skip to content

Conversation

@emiliosheinz
Copy link
Contributor

@emiliosheinz emiliosheinz commented Oct 28, 2025

Adds a safe fallback for util.styleText on Node.js versions earlier than 20.12.0, where the API is not yet available.

When util.styleText is missing, the fallback simply returns the unmodified text. This prevents runtime errors and maintains compatibility across environments running different Node versions.

Motivation

util.styleText was 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

  • Introduced a centralized fallback for util.styleText.
  • Ensures consistent behavior across Node ≥ 18.x and ≥ 20.12.0.
  • Avoids runtime errors in older Node versions.

Example

styleText('bold', 'Hello'); // styled on Node ≥ 20.12.0, plain text otherwise

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.

@changeset-bot
Copy link

changeset-bot bot commented Oct 28, 2025

🦋 Changeset detected

Latest commit: 0f23556

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@react-email/preview-server Patch
react-email Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Oct 28, 2025

@emiliosheinz is attempting to deploy a commit to the resend Team on Vercel.

A member of the Team first needs to authorize it.

@emiliosheinz
Copy link
Contributor Author

Node 24

image

Node 18

image

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 28, 2025

Open in StackBlitz

npm i https://pkg.pr.new/resend/react-email/@react-email/preview-server@2606
npm i https://pkg.pr.new/resend/react-email@2606

commit: c3b2cf2

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 4 files

Copy link
Member

@gabrielmfern gabrielmfern left a comment

Choose a reason for hiding this comment

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

great work, thank you!

@gabrielmfern gabrielmfern merged commit 1b3176e into resend:canary Oct 29, 2025
6 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The requested module 'node:util' does not provide an export named 'styleText'

2 participants