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

feat(render): Use prettier's standalone API instead of js-beautify #1777

Merged
merged 3 commits into from
Nov 19, 2024

Conversation

gabrielmfern
Copy link
Collaborator

@gabrielmfern gabrielmfern commented Nov 14, 2024

This is a no-brainer decision for four reasons:

  1. Prettier is much more well maintained
  2. Prettier's standalone is smaller than js-beautify
  3. Prettier does not force us to do weird finagling to work with ESM and CJS
  4. Prettier's formatting is much prettier

Copy link

vercel bot commented Nov 14, 2024

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

Name Status Preview Comments Updated (UTC)
react-email ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 14, 2024 4:06pm
react-email-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 14, 2024 4:06pm

Copy link

changeset-bot bot commented Nov 14, 2024

🦋 Changeset detected

Latest commit: 16a1880

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

This PR includes changesets to release 13 packages
Name Type
@react-email/render Patch
@react-email/components Patch
react-email-with-aws-ses Patch
react-email-with-mailersend Patch
react-email-with-nodemailer Patch
react-email-with-plunk Patch
react-email-with-postmark Patch
react-email-with-resend Patch
react-email-with-sendgrid Patch
react-email-with-next-scaleway Patch
react-email-with-node-scaleway Patch
react-email-starter Patch
create-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

@gabrielmfern gabrielmfern merged commit addbf49 into canary Nov 19, 2024
10 checks passed
@gabrielmfern gabrielmfern deleted the chore/remove-usage-of-js-beautify branch November 19, 2024 13:24
@chadxz
Copy link

chadxz commented Dec 12, 2024

hey @gabrielmfern, ran into this issue after upgrading @react-email/components to v0.0.29 (which included this).

TypeError: Cannot read properties of undefined (reading 'languages')
    at /Users/chad/src/smartrr/node_modules/prettier/standalone.js:24:694
    at Array.flatMap (<anonymous>)
    at it (/Users/chad/src/smartrr/node_modules/prettier/standalone.js:24:681)
    at Ai (/Users/chad/src/smartrr/node_modules/prettier/standalone.js:27:12039)
    at rr (/Users/chad/src/smartrr/node_modules/prettier/standalone.js:33:273)
    at /Users/chad/src/smartrr/node_modules/prettier/standalone.js:35:802
    at gu (/Users/chad/src/smartrr/node_modules/prettier/standalone.js:35:871)
    at pretty (/Users/chad/src/smartrr/node_modules/@react-email/render/dist/node/index.js:87:39)
    at /Users/chad/src/smartrr/node_modules/@react-email/render/dist/node/index.js:163:12
    at Generator.next (<anonymous>)
    at fulfilled (/Users/chad/src/smartrr/node_modules/@react-email/render/dist/node/index.js:47:24)
    at processTicksAndRejections (node:internal/process/task_queues:105:5)

Some research landed me on prettier/prettier#16155 which suggests there's something about my environment (Node+TypeScript compiling down to CJS) that is likely causing it.

I was able to remove { pretty: true } from my renderToString call and it unblocked me for now, but thought I'd mention it.

jctf pushed a commit to jctf/react-email that referenced this pull request Dec 17, 2024
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