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

Can not work pretty: true render #1802

Open
k725 opened this issue Dec 4, 2024 · 6 comments
Open

Can not work pretty: true render #1802

k725 opened this issue Dec 4, 2024 · 6 comments

Comments

@k725
Copy link

k725 commented Dec 4, 2024

Describe the Bug

Specify pretty: true in render(), an exception will be thrown.

Which package is affected (leave empty if unsure)

@react-email/render

Link to the code that reproduces this issue

https://github.com/k725/reproduce-react-email-pretty-error

To Reproduce

git clone https://github.com/k725/reproduce-react-email-pretty-error
cd reproduce-react-email-pretty-error
npm i
npm run build-tsc

# work
node index-no-pretty.js 

# throw error
node index-pretty.js 

Expected Behavior

Return rendered html.

What's your node version? (if relevant)

v22.12.0

@k725 k725 added the Type: Bug Confirmed bug label Dec 4, 2024
@gabrielmfern
Copy link
Collaborator

The link for the reproduction seems to be down

@k725
Copy link
Author

k725 commented Dec 5, 2024

@gabrielmfern I accidentally made the repository private. I changed it to public so please check.

@SPodjasek
Copy link

I've run into similar issue, but it seems to be related to prettier being very standards compliant.
My exception shows:

SyntaxError: Unexpected closing tag "td". It may happen when the tag has already been closed 
by another tag. For more info see 
https://www.w3.org/TR/html5/syntax.html#closing-elements-that-have-implied-end-tags (2:231)

@SPodjasek
Copy link

SPodjasek commented Dec 19, 2024

It was working properly with @react-email/components at version 0.0.19 and stopped working after upgrade to 0.0.31.

I've managed to narrow it down to version 0.0.29 in which the issue started to appear. This components version uses @react-email/[email protected] which depends on [email protected].

@mririgoyen
Copy link

Can confirm that this is indeed an issue with the pretty flag. When using the pretty flag, a TypeError is dumped to the console:

TypeError: Cannot read properties of undefined (reading 'languages')
    at /my-project/node_modules/prettier/standalone.js:28:694
    at Array.flatMap (<anonymous>)
    at st (/my-project/node_modules/prettier/standalone.js:28:681)
    at vi (/my-project/node_modules/prettier/standalone.js:31:12039)
    at sr (/my-project/node_modules/prettier/standalone.js:37:273)
    at /my-project/node_modules/prettier/standalone.js:39:802
    at gu (/my-project/node_modules/prettier/standalone.js:39:871)
    at pretty (/my-project/node_modules/@react-email/render/dist/node/index.js:87:39)
    at /my-project/node_modules/@react-email/render/dist/node/index.js:163:12
    at Generator.next (<anonymous>)

@gewfy
Copy link

gewfy commented Jan 14, 2025

Same issue here with Cannot read properties of undefined . Also reported here #1777 (comment)

@gabrielmfern gabrielmfern removed the Resolution: Can't Reproduce This issue cannot be reproduced label Jan 14, 2025
DeepaPrasanna added a commit to DeepaPrasanna/twenty that referenced this issue Jan 22, 2025
add await and remove {pretty :true} to fix this issue resend/react-email#1802
DeepaPrasanna added a commit to DeepaPrasanna/twenty that referenced this issue Jan 27, 2025
add await and remove {pretty :true} to fix this issue resend/react-email#1802
DeepaPrasanna added a commit to DeepaPrasanna/twenty that referenced this issue Jan 28, 2025
add await and remove {pretty :true} to fix this issue resend/react-email#1802
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants