react-email 4.3.0 → 4.3.1
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/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -70,8 +70,7 @@ const getEmailsDirectoryMetadata = async (absolutePathToEmailsDirectory, keepFil
|
|
|
70
70
|
const isEmailPredicates = await Promise.all(dirents.map((dirent) => isFileAnEmail(path.join(absolutePathToEmailsDirectory, dirent.name))));
|
|
71
71
|
const emailFilenames = dirents.filter((_, i) => isEmailPredicates[i]).map((dirent) => keepFileExtensions ? dirent.name : dirent.name.replace(path.extname(dirent.name), ""));
|
|
72
72
|
const subDirectories = await Promise.all(dirents.filter((dirent) => dirent.isDirectory() && !dirent.name.startsWith("_") && dirent.name !== "static").map((dirent) => {
|
|
73
|
-
|
|
74
|
-
return getEmailsDirectoryMetadata(direntAbsolutePath, keepFileExtensions, true, baseDirectoryPath);
|
|
73
|
+
return getEmailsDirectoryMetadata(path.join(absolutePathToEmailsDirectory, dirent.name), keepFileExtensions, true, baseDirectoryPath);
|
|
75
74
|
}));
|
|
76
75
|
const emailsMetadata = {
|
|
77
76
|
absolutePath: absolutePathToEmailsDirectory,
|
|
@@ -86,7 +85,7 @@ const getEmailsDirectoryMetadata = async (absolutePathToEmailsDirectory, keepFil
|
|
|
86
85
|
//#endregion
|
|
87
86
|
//#region package.json
|
|
88
87
|
var name = "react-email";
|
|
89
|
-
var version = "4.3.
|
|
88
|
+
var version = "4.3.1";
|
|
90
89
|
var description = "A live preview of your emails right in your browser.";
|
|
91
90
|
var bin = { "email": "./dist/index.js" };
|
|
92
91
|
var type = "module";
|
|
@@ -268,15 +267,14 @@ module.exports = {
|
|
|
268
267
|
const getEmailSlugsFromEmailDirectory = (emailDirectory, emailsDirectoryAbsolutePath) => {
|
|
269
268
|
const directoryPathRelativeToEmailsDirectory = emailDirectory.absolutePath.replace(emailsDirectoryAbsolutePath, "").trim();
|
|
270
269
|
const slugs = [];
|
|
271
|
-
emailDirectory.emailFilenames.forEach((filename
|
|
270
|
+
emailDirectory.emailFilenames.forEach((filename) => slugs.push(path.join(directoryPathRelativeToEmailsDirectory, filename).split(path.sep).filter((segment) => segment.length > 0)));
|
|
272
271
|
emailDirectory.subDirectories.forEach((directory) => {
|
|
273
272
|
slugs.push(...getEmailSlugsFromEmailDirectory(directory, emailsDirectoryAbsolutePath));
|
|
274
273
|
});
|
|
275
274
|
return slugs;
|
|
276
275
|
};
|
|
277
276
|
const forceSSGForEmailPreviews = async (emailsDirPath, builtPreviewAppPath) => {
|
|
278
|
-
const
|
|
279
|
-
const parameters = getEmailSlugsFromEmailDirectory(emailDirectoryMetadata, emailsDirPath).map((slug) => ({ slug }));
|
|
277
|
+
const parameters = getEmailSlugsFromEmailDirectory(await getEmailsDirectoryMetadata(emailsDirPath), emailsDirPath).map((slug) => ({ slug }));
|
|
280
278
|
const removeForceDynamic = async (filePath) => {
|
|
281
279
|
const contents = await fs.promises.readFile(filePath, "utf8");
|
|
282
280
|
await fs.promises.writeFile(filePath, contents.replace("export const dynamic = 'force-dynamic';", ""), "utf8");
|
|
@@ -356,7 +354,7 @@ const build$1 = async ({ dir: emailsDirRelativePath, packageManager }) => {
|
|
|
356
354
|
const traverse = typeof traverseModule === "function" ? traverseModule : traverseModule.default;
|
|
357
355
|
const getImportedModules = (contents) => {
|
|
358
356
|
const importedPaths = [];
|
|
359
|
-
|
|
357
|
+
traverse(parse(contents, {
|
|
360
358
|
sourceType: "unambiguous",
|
|
361
359
|
strictMode: false,
|
|
362
360
|
errorRecovery: true,
|
|
@@ -365,8 +363,7 @@ const getImportedModules = (contents) => {
|
|
|
365
363
|
"typescript",
|
|
366
364
|
"decorators"
|
|
367
365
|
]
|
|
368
|
-
})
|
|
369
|
-
traverse(parsedContents, {
|
|
366
|
+
}), {
|
|
370
367
|
ImportDeclaration({ node }) {
|
|
371
368
|
importedPaths.push(node.source.value);
|
|
372
369
|
},
|
|
@@ -477,11 +474,8 @@ const createDependencyGraph = async (directory) => {
|
|
|
477
474
|
}
|
|
478
475
|
const extension = path.extname(pathToDependencyFromDirectory);
|
|
479
476
|
const pathWithEnsuredExtension = (() => {
|
|
480
|
-
if (extension.length > 0 &&
|
|
481
|
-
|
|
482
|
-
return checkFileExtensionsUntilItExists(pathToDependencyFromDirectory.replace(extension, ""));
|
|
483
|
-
}
|
|
484
|
-
return checkFileExtensionsUntilItExists(pathToDependencyFromDirectory);
|
|
477
|
+
if (extension.length > 0 && existsSync(pathToDependencyFromDirectory)) return pathToDependencyFromDirectory;
|
|
478
|
+
return checkFileExtensionsUntilItExists(pathToDependencyFromDirectory.replace(extension, ""));
|
|
485
479
|
})();
|
|
486
480
|
if (pathWithEnsuredExtension) pathToDependencyFromDirectory = pathWithEnsuredExtension;
|
|
487
481
|
else console.warn(`Could not find file at ${pathToDependencyFromDirectory}`);
|
|
@@ -552,8 +546,7 @@ const createDependencyGraph = async (directory) => {
|
|
|
552
546
|
const dependentPaths = /* @__PURE__ */ new Set();
|
|
553
547
|
const stack = [pathToModule];
|
|
554
548
|
while (stack.length > 0) {
|
|
555
|
-
const
|
|
556
|
-
const moduleEntry = graph[currentPath];
|
|
549
|
+
const moduleEntry = graph[stack.pop()];
|
|
557
550
|
if (!moduleEntry) continue;
|
|
558
551
|
for (const dependentPath of moduleEntry.dependentPaths) {
|
|
559
552
|
if (dependentPaths.has(dependentPath) || dependentPath === pathToModule) continue;
|
|
@@ -811,8 +804,7 @@ const getTreeLines = async (dirPath, depth, currentDepth = 0) => {
|
|
|
811
804
|
const verticalSymbol = isLast ? SYMBOLS.INDENT : SYMBOLS.VERTICAL;
|
|
812
805
|
if (dirent.isFile()) lines.push(`${branchingSymbol}${dirent.name}`);
|
|
813
806
|
else {
|
|
814
|
-
const
|
|
815
|
-
const treeLinesForSubDirectory = await getTreeLines(pathToDirectory, depth, currentDepth + 1);
|
|
807
|
+
const treeLinesForSubDirectory = await getTreeLines(path.join(dirFullpath, dirent.name), depth, currentDepth + 1);
|
|
816
808
|
lines = lines.concat(treeLinesForSubDirectory.map((line, index) => index === 0 ? `${branchingSymbol}${line}` : `${verticalSymbol}${line}`));
|
|
817
809
|
}
|
|
818
810
|
}
|
|
@@ -831,8 +823,7 @@ const dev = async ({ dir: emailsDirRelativePath, port }) => {
|
|
|
831
823
|
console.error(`Missing ${emailsDirRelativePath} folder`);
|
|
832
824
|
process.exit(1);
|
|
833
825
|
}
|
|
834
|
-
|
|
835
|
-
await setupHotreloading(devServer$1, emailsDirRelativePath);
|
|
826
|
+
await setupHotreloading(await startDevServer(emailsDirRelativePath, emailsDirRelativePath, Number.parseInt(port)), emailsDirRelativePath);
|
|
836
827
|
} catch (error) {
|
|
837
828
|
console.log(error);
|
|
838
829
|
process.exit(1);
|
|
@@ -890,14 +881,13 @@ const renderingUtilitiesExporter = (emailTemplates) => ({
|
|
|
890
881
|
//#region src/commands/export.ts
|
|
891
882
|
const getEmailTemplatesFromDirectory = (emailDirectory) => {
|
|
892
883
|
const templatePaths = [];
|
|
893
|
-
emailDirectory.emailFilenames.forEach((filename
|
|
884
|
+
emailDirectory.emailFilenames.forEach((filename) => templatePaths.push(path.join(emailDirectory.absolutePath, filename)));
|
|
894
885
|
emailDirectory.subDirectories.forEach((directory) => {
|
|
895
886
|
templatePaths.push(...getEmailTemplatesFromDirectory(directory));
|
|
896
887
|
});
|
|
897
888
|
return templatePaths;
|
|
898
889
|
};
|
|
899
|
-
const
|
|
900
|
-
const require = createRequire(filename);
|
|
890
|
+
const require = createRequire(url.fileURLToPath(import.meta.url));
|
|
901
891
|
const exportTemplates = async (pathToWhereEmailMarkupShouldBeDumped, emailsDirectoryPath, options) => {
|
|
902
892
|
if (fs.existsSync(pathToWhereEmailMarkupShouldBeDumped)) fs.rmSync(pathToWhereEmailMarkupShouldBeDumped, { recursive: true });
|
|
903
893
|
let spinner;
|
|
@@ -947,8 +937,7 @@ const exportTemplates = async (pathToWhereEmailMarkupShouldBeDumped, emailsDirec
|
|
|
947
937
|
delete require.cache[template];
|
|
948
938
|
const emailModule = require(template);
|
|
949
939
|
const rendered = await emailModule.render(emailModule.reactEmailCreateReactElement(emailModule.default, {}), options);
|
|
950
|
-
|
|
951
|
-
writeFileSync(htmlPath, rendered);
|
|
940
|
+
writeFileSync(template.replace(".cjs", options.plainText ? ".txt" : ".html"), rendered);
|
|
952
941
|
unlinkSync(template);
|
|
953
942
|
} catch (exception) {
|
|
954
943
|
if (spinner) spinner.stopAndPersist({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-email",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.1",
|
|
4
4
|
"description": "A live preview of your emails right in your browser.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"email": "./dist/index.js"
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"react": "19.0.0",
|
|
47
47
|
"react-dom": "19.0.0",
|
|
48
48
|
"typescript": "5.8.3",
|
|
49
|
-
"@react-email/components": "0.5.
|
|
49
|
+
"@react-email/components": "0.5.7"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
52
|
"build": "tsdown",
|
|
@@ -146,17 +146,12 @@ export const createDependencyGraph = async (directory: string) => {
|
|
|
146
146
|
const pathWithEnsuredExtension = (() => {
|
|
147
147
|
if (
|
|
148
148
|
extension.length > 0 &&
|
|
149
|
-
|
|
149
|
+
existsSync(pathToDependencyFromDirectory)
|
|
150
150
|
) {
|
|
151
|
-
|
|
152
|
-
return pathToDependencyFromDirectory;
|
|
153
|
-
}
|
|
154
|
-
return checkFileExtensionsUntilItExists(
|
|
155
|
-
pathToDependencyFromDirectory.replace(extension, ''),
|
|
156
|
-
);
|
|
151
|
+
return pathToDependencyFromDirectory;
|
|
157
152
|
}
|
|
158
153
|
return checkFileExtensionsUntilItExists(
|
|
159
|
-
pathToDependencyFromDirectory,
|
|
154
|
+
pathToDependencyFromDirectory.replace(extension, ''),
|
|
160
155
|
);
|
|
161
156
|
})();
|
|
162
157
|
|