email export: `--outDir` outside the project fails for `<Tailwind>` templates with "Cannot find module 'css-tree/dist/csstree.esm'" (since 6.8.0)
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 76/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- node.js, react, typescript
調査の方向性
Start at the email export CLI implementation and the change in #3643 that made the Tailwind path import css-tree/dist/csstree.esm. Trace how the export bundle is written and how its dependencies are resolved when --outDir is outside the project. Reproduce with the supplied Tailwind template and external output directory; done when it creates welcome.html and exits successfully, while default output still works.
索引モデルが issue の本文から書いたものです。
説明
What versions are you using? (if relevant)
react-email 6.11.13 (latest), react and react-dom 19.3.1, npm 11.16.0, macOS. It works on 6.7.0 and fails on 6.8.0, 6.9.0, 6.10.0, 6.11.12 and 6.11.13, so it looks like a regression in 6.8.0. The npm canary tag is 6.0.0-canary.2, older than latest, so I couldn't test a newer canary.
Describe the Bug
I wanted to export my templates straight into a sibling backend folder with email export --outDir ../backend/templates. For any template that uses <Tailwind>, it fails with:
Error: Error: Cannot find module 'css-tree/dist/csstree.esm'
Require stack:
- /path/to/backend/templates/welcome.cjs
It exits 1, writes no .html, and leaves welcome.cjs (about 35k lines) in the output folder. The same template exports fine to the default out. A template without <Tailwind> exports fine to the same outside folder. An outDir under $TMPDIR or $HOME fails the same way, with or without --plainText or --pretty. Running it with NODE_PATH=$PWD/node_modules works, and so does exporting to another folder inside an npm workspaces repo where css-tree is hoisted to the root.
It looks like the bundle keeps css-tree external and is then required from the outDir, and since 6.8.0 (#3643) the Tailwind code imports css-tree/dist/csstree.esm instead of inlining css-tree.
What is affected (leave empty if unsure)
CLI (email export)
Link to the code that reproduces this issue
No repo: the whole reproduction is one file and two commands, below.
To Reproduce
In an empty folder my-emails, next to an empty folder backend:
npm install react-email react react-dom -E
emails/welcome.tsx:
import { Html, Tailwind, Text } from "react-email";
export default function Welcome() {
return (
<Html>
<Tailwind>
<Text className="text-blue-600">Hello</Text>
</Tailwind>
</Html>
);
}
npx email export --outDir ../backend/templates
Result: the error above, exit code 1, and only ../backend/templates/welcome.cjs. npx email export with the default out gives out/welcome.html.
Expected Behavior
../backend/templates/welcome.html and exit code 0. The CLI page documents --outDir as "Change the output directory." and lists "When the email content must be processed by a backend in a language other than JavaScript." as a reason to use email export, so exporting into a backend folder seemed like the intended use.
What's your node version? (if relevant)
v26.3.0
- 主要言語
- TypeScript
- スター
- 20k
- フォーク
- 1.1k
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 80
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
resend/react-email のほかの issue
-
Heading: margin shortcut props (m, mt, mx, ...) produce invalid CSS for values with units such as "1.5rem" or "10px"対応中かも @officialasishkumar が 1 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 35/100
resend/react-email#3924 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
resend/react-email#3878 · コメント 2 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Dependency Dashboardオープンdependencies
難易度 5/5 1週間以上 初心者へのやさしさ 15/100
resend/react-email#746 ·
メンテナーはふだん 1 日以内に返信
resend/react-email の issue をすべて見る
似ている issue
-
Bug Tests
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
JSPrismarine/JSPrismarine#3384 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
zingolabs/zingo-mobile#1951 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
Automattic/data-liberation-agent#2175 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
xdelmo/Portfolio-minimal#613 ·
メンテナーはふだん 1 日以内に返信
-
backend documentation low-priority Stellar Wave
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
Savitura/Savitools#611 · コメント 1 件 ·
メンテナーはふだん 6 日以内に返信