react-email 4.3.0 → 4.3.2

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
@@ -1,5 +1,13 @@
1
1
  # react-email
2
2
 
3
+ ## 4.3.2
4
+
5
+ ## 4.3.1
6
+
7
+ ### Patch Changes
8
+
9
+ - 1e13d15: hot reloading errors when importing .json and other file extensions
10
+
3
11
  ## 4.3.0
4
12
 
5
13
  ## 4.2.12
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
- const direntAbsolutePath = path.join(absolutePathToEmailsDirectory, dirent.name);
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.0";
88
+ var version = "4.3.2";
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$1) => slugs.push(path.join(directoryPathRelativeToEmailsDirectory, filename$1).split(path.sep).filter((segment) => segment.length > 0)));
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 emailDirectoryMetadata = await getEmailsDirectoryMetadata(emailsDirPath);
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
- const parsedContents = parse(contents, {
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,10 +474,8 @@ const createDependencyGraph = async (directory) => {
477
474
  }
478
475
  const extension = path.extname(pathToDependencyFromDirectory);
479
476
  const pathWithEnsuredExtension = (() => {
480
- if (extension.length > 0 && javascriptExtensions.includes(extension)) {
481
- if (existsSync(pathToDependencyFromDirectory)) return pathToDependencyFromDirectory;
482
- return checkFileExtensionsUntilItExists(pathToDependencyFromDirectory.replace(extension, ""));
483
- }
477
+ if (extension.length > 0 && existsSync(pathToDependencyFromDirectory)) return pathToDependencyFromDirectory;
478
+ if (javascriptExtensions.includes(extension)) return checkFileExtensionsUntilItExists(pathToDependencyFromDirectory.replace(extension, ""));
484
479
  return checkFileExtensionsUntilItExists(pathToDependencyFromDirectory);
485
480
  })();
486
481
  if (pathWithEnsuredExtension) pathToDependencyFromDirectory = pathWithEnsuredExtension;
@@ -552,8 +547,7 @@ const createDependencyGraph = async (directory) => {
552
547
  const dependentPaths = /* @__PURE__ */ new Set();
553
548
  const stack = [pathToModule];
554
549
  while (stack.length > 0) {
555
- const currentPath = stack.pop();
556
- const moduleEntry = graph[currentPath];
550
+ const moduleEntry = graph[stack.pop()];
557
551
  if (!moduleEntry) continue;
558
552
  for (const dependentPath of moduleEntry.dependentPaths) {
559
553
  if (dependentPaths.has(dependentPath) || dependentPath === pathToModule) continue;
@@ -811,8 +805,7 @@ const getTreeLines = async (dirPath, depth, currentDepth = 0) => {
811
805
  const verticalSymbol = isLast ? SYMBOLS.INDENT : SYMBOLS.VERTICAL;
812
806
  if (dirent.isFile()) lines.push(`${branchingSymbol}${dirent.name}`);
813
807
  else {
814
- const pathToDirectory = path.join(dirFullpath, dirent.name);
815
- const treeLinesForSubDirectory = await getTreeLines(pathToDirectory, depth, currentDepth + 1);
808
+ const treeLinesForSubDirectory = await getTreeLines(path.join(dirFullpath, dirent.name), depth, currentDepth + 1);
816
809
  lines = lines.concat(treeLinesForSubDirectory.map((line, index) => index === 0 ? `${branchingSymbol}${line}` : `${verticalSymbol}${line}`));
817
810
  }
818
811
  }
@@ -831,8 +824,7 @@ const dev = async ({ dir: emailsDirRelativePath, port }) => {
831
824
  console.error(`Missing ${emailsDirRelativePath} folder`);
832
825
  process.exit(1);
833
826
  }
834
- const devServer$1 = await startDevServer(emailsDirRelativePath, emailsDirRelativePath, Number.parseInt(port));
835
- await setupHotreloading(devServer$1, emailsDirRelativePath);
827
+ await setupHotreloading(await startDevServer(emailsDirRelativePath, emailsDirRelativePath, Number.parseInt(port)), emailsDirRelativePath);
836
828
  } catch (error) {
837
829
  console.log(error);
838
830
  process.exit(1);
@@ -890,14 +882,13 @@ const renderingUtilitiesExporter = (emailTemplates) => ({
890
882
  //#region src/commands/export.ts
891
883
  const getEmailTemplatesFromDirectory = (emailDirectory) => {
892
884
  const templatePaths = [];
893
- emailDirectory.emailFilenames.forEach((filename$1) => templatePaths.push(path.join(emailDirectory.absolutePath, filename$1)));
885
+ emailDirectory.emailFilenames.forEach((filename) => templatePaths.push(path.join(emailDirectory.absolutePath, filename)));
894
886
  emailDirectory.subDirectories.forEach((directory) => {
895
887
  templatePaths.push(...getEmailTemplatesFromDirectory(directory));
896
888
  });
897
889
  return templatePaths;
898
890
  };
899
- const filename = url.fileURLToPath(import.meta.url);
900
- const require = createRequire(filename);
891
+ const require = createRequire(url.fileURLToPath(import.meta.url));
901
892
  const exportTemplates = async (pathToWhereEmailMarkupShouldBeDumped, emailsDirectoryPath, options) => {
902
893
  if (fs.existsSync(pathToWhereEmailMarkupShouldBeDumped)) fs.rmSync(pathToWhereEmailMarkupShouldBeDumped, { recursive: true });
903
894
  let spinner;
@@ -947,8 +938,7 @@ const exportTemplates = async (pathToWhereEmailMarkupShouldBeDumped, emailsDirec
947
938
  delete require.cache[template];
948
939
  const emailModule = require(template);
949
940
  const rendered = await emailModule.render(emailModule.reactEmailCreateReactElement(emailModule.default, {}), options);
950
- const htmlPath = template.replace(".cjs", options.plainText ? ".txt" : ".html");
951
- writeFileSync(htmlPath, rendered);
941
+ writeFileSync(template.replace(".cjs", options.plainText ? ".txt" : ".html"), rendered);
952
942
  unlinkSync(template);
953
943
  } catch (exception) {
954
944
  if (spinner) spinner.stopAndPersist({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-email",
3
- "version": "4.3.0",
3
+ "version": "4.3.2",
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.6"
49
+ "@react-email/components": "0.5.7"
50
50
  },
51
51
  "scripts": {
52
52
  "build": "tsdown",
@@ -146,11 +146,11 @@ export const createDependencyGraph = async (directory: string) => {
146
146
  const pathWithEnsuredExtension = (() => {
147
147
  if (
148
148
  extension.length > 0 &&
149
- javascriptExtensions.includes(extension)
149
+ existsSync(pathToDependencyFromDirectory)
150
150
  ) {
151
- if (existsSync(pathToDependencyFromDirectory)) {
152
- return pathToDependencyFromDirectory;
153
- }
151
+ return pathToDependencyFromDirectory;
152
+ }
153
+ if (javascriptExtensions.includes(extension)) {
154
154
  return checkFileExtensionsUntilItExists(
155
155
  pathToDependencyFromDirectory.replace(extension, ''),
156
156
  );