react-email 2.1.3 → 2.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/index.js +464 -367
- package/cli/index.mjs +304 -239
- package/package.json +6 -5
- package/src/actions/get-email-path-from-slug.ts +5 -3
- package/src/utils/render-resolver-esbuild-plugin.ts +11 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-email",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.4",
|
|
4
4
|
"description": "A live preview of your emails right in your browser.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"email": "./cli/index.js"
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"node": ">=18.0.0"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@babel/
|
|
22
|
+
"@babel/core": "7.24.5",
|
|
23
|
+
"@babel/parser": "7.24.5",
|
|
23
24
|
"@radix-ui/colors": "1.0.1",
|
|
24
25
|
"@radix-ui/react-collapsible": "1.0.3",
|
|
25
26
|
"@radix-ui/react-popover": "1.0.7",
|
|
@@ -31,7 +32,6 @@
|
|
|
31
32
|
"@types/react-dom": "^18.2.0",
|
|
32
33
|
"@types/webpack": "5.28.5",
|
|
33
34
|
"autoprefixer": "10.4.14",
|
|
34
|
-
"babel-walk": "3.0.0",
|
|
35
35
|
"chalk": "4.1.2",
|
|
36
36
|
"chokidar": "3.5.3",
|
|
37
37
|
"clsx": "2.1.0",
|
|
@@ -62,8 +62,9 @@
|
|
|
62
62
|
"typescript": "5.1.6"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@react-email/components": "0.0.
|
|
66
|
-
"@react-email/render": "0.0.
|
|
65
|
+
"@react-email/components": "0.0.19",
|
|
66
|
+
"@react-email/render": "0.0.15",
|
|
67
|
+
"@types/babel__core": "7.20.5",
|
|
67
68
|
"@types/fs-extra": "11.0.1",
|
|
68
69
|
"@types/mime-types": "2.1.4",
|
|
69
70
|
"@types/node": "18.0.0",
|
|
@@ -5,7 +5,7 @@ import { emailsDirectoryAbsolutePath } from '../utils/emails-directory-absolute-
|
|
|
5
5
|
|
|
6
6
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
7
7
|
export const getEmailPathFromSlug = async (slug: string) => {
|
|
8
|
-
if (['.tsx', '.jsx', '.js'].includes(path.extname(slug)))
|
|
8
|
+
if (['.tsx', '.jsx', '.ts', '.js'].includes(path.extname(slug)))
|
|
9
9
|
return path.join(emailsDirectoryAbsolutePath, slug);
|
|
10
10
|
|
|
11
11
|
const pathWithoutExtension = path.join(emailsDirectoryAbsolutePath, slug);
|
|
@@ -14,12 +14,14 @@ export const getEmailPathFromSlug = async (slug: string) => {
|
|
|
14
14
|
return `${pathWithoutExtension}.tsx`;
|
|
15
15
|
} else if (fs.existsSync(`${pathWithoutExtension}.jsx`)) {
|
|
16
16
|
return `${pathWithoutExtension}.jsx`;
|
|
17
|
+
} else if (fs.existsSync(`${pathWithoutExtension}.ts`)) {
|
|
18
|
+
return `${pathWithoutExtension}.ts`;
|
|
17
19
|
} else if (fs.existsSync(`${pathWithoutExtension}.js`)) {
|
|
18
|
-
return `${pathWithoutExtension}.
|
|
20
|
+
return `${pathWithoutExtension}.js`;
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
throw new Error(
|
|
22
|
-
`Could not find your email file based on the slug (${slug}) by guessing the file extension. Tried .tsx, .jsx and .js.
|
|
24
|
+
`Could not find your email file based on the slug (${slug}) by guessing the file extension. Tried .tsx, .jsx, .ts and .js.
|
|
23
25
|
|
|
24
26
|
This is most likely not an issue with the preview server. It most likely is that the email doesn't exist.`,
|
|
25
27
|
);
|
|
@@ -2,6 +2,10 @@ import path from 'node:path';
|
|
|
2
2
|
import { promises as fs } from 'node:fs';
|
|
3
3
|
import type { Loader, PluginBuild, ResolveOptions } from 'esbuild';
|
|
4
4
|
|
|
5
|
+
function escapeStringForRegex(string: string) {
|
|
6
|
+
return string.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d');
|
|
7
|
+
}
|
|
8
|
+
|
|
5
9
|
/**
|
|
6
10
|
* Made to export the `renderAsync` function out of the user's email template
|
|
7
11
|
* so that issues like https://github.com/resend/react-email/issues/649 don't
|
|
@@ -14,7 +18,13 @@ export const renderResolver = (emailTemplates: string[]) => ({
|
|
|
14
18
|
name: 'render-resolver',
|
|
15
19
|
setup: (b: PluginBuild) => {
|
|
16
20
|
b.onLoad(
|
|
17
|
-
{
|
|
21
|
+
{
|
|
22
|
+
filter: new RegExp(
|
|
23
|
+
emailTemplates
|
|
24
|
+
.map((emailPath) => escapeStringForRegex(emailPath))
|
|
25
|
+
.join('|'),
|
|
26
|
+
),
|
|
27
|
+
},
|
|
18
28
|
async ({ path: pathToFile }) => {
|
|
19
29
|
return {
|
|
20
30
|
contents: `${await fs.readFile(pathToFile, 'utf8')};
|