react-email 2.1.0 → 2.1.1-canary.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/cli/index.js CHANGED
@@ -200,6 +200,20 @@ function _ts_generator(thisArg, body) {
200
200
  };
201
201
  }
202
202
  }
203
+ function _ts_values(o) {
204
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
205
+ if (m) return m.call(o);
206
+ if (o && typeof o.length === "number") return {
207
+ next: function() {
208
+ if (o && i >= o.length) o = void 0;
209
+ return {
210
+ value: o && o[i++],
211
+ done: !o
212
+ };
213
+ }
214
+ };
215
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
216
+ }
203
217
  var __create = Object.create;
204
218
  var __defProp = Object.defineProperty;
205
219
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -252,7 +266,7 @@ var import_commander = require("commander");
252
266
  // package.json
253
267
  var package_default = {
254
268
  name: "react-email",
255
- version: "2.1.0",
269
+ version: "2.1.1-canary.1",
256
270
  description: "A live preview of your emails right in your browser.",
257
271
  bin: {
258
272
  email: "./cli/index.js"
@@ -280,11 +294,11 @@ var package_default = {
280
294
  dependencies: {
281
295
  "@radix-ui/colors": "1.0.1",
282
296
  "@radix-ui/react-collapsible": "1.0.3",
283
- "@radix-ui/react-popover": "1.0.6",
297
+ "@radix-ui/react-popover": "1.0.7",
284
298
  "@radix-ui/react-slot": "1.0.2",
285
299
  "@radix-ui/react-toggle-group": "1.0.4",
286
300
  "@radix-ui/react-tooltip": "1.0.6",
287
- "@react-email/components": "0.0.15",
301
+ "@react-email/components": "0.0.16-canary.1",
288
302
  "@react-email/render": "0.0.12",
289
303
  "@swc/core": "1.3.101",
290
304
  "@types/react": "^18.2.0",
@@ -318,7 +332,6 @@ var package_default = {
318
332
  "stacktrace-parser": "0.1.10",
319
333
  "tailwind-merge": "2.2.0",
320
334
  tailwindcss: "3.4.0",
321
- "tree-cli": "0.6.7",
322
335
  typescript: "5.1.6"
323
336
  },
324
337
  devDependencies: {
@@ -330,43 +343,158 @@ var package_default = {
330
343
  "@vercel/style-guide": "5.1.0",
331
344
  eslint: "8.50.0",
332
345
  tsup: "7.2.0",
333
- tsx: "4.7.0",
346
+ tsx: "4.7.1",
334
347
  vitest: "1.1.3",
335
348
  watch: "1.0.2"
336
349
  }
337
350
  };
338
351
  // src/cli/commands/dev.ts
339
- var import_node_fs2 = __toESM(require("fs"));
352
+ var import_node_fs3 = __toESM(require("fs"));
340
353
  // src/cli/utils/tree.ts
341
- var import_tree_cli = __toESM(require("tree-cli"));
342
- var tree = function() {
343
- var _ref = _async_to_generator(function(dir, depth) {
344
- var report;
354
+ var import_node_fs = require("fs");
355
+ var import_node_os = __toESM(require("os"));
356
+ var import_node_path = __toESM(require("path"));
357
+ var SYMBOLS = {
358
+ BRANCH: "├── ",
359
+ EMPTY: "",
360
+ INDENT: " ",
361
+ LAST_BRANCH: "└── ",
362
+ VERTICAL: "│ "
363
+ };
364
+ var getTreeLines = function() {
365
+ var _ref = _async_to_generator(function(dirPath, depth) {
366
+ var currentDepth, base, dirFullpath, dirname, lines, dirStat, _loop, childDirents, i;
367
+ var _arguments = arguments;
345
368
  return _ts_generator(this, function(_state) {
346
369
  switch(_state.label){
347
370
  case 0:
371
+ currentDepth = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : 0;
372
+ base = process.cwd();
373
+ dirFullpath = import_node_path.default.resolve(base, dirPath);
374
+ dirname = import_node_path.default.basename(dirFullpath);
375
+ lines = [
376
+ dirname
377
+ ];
348
378
  return [
349
379
  4,
350
- (0, import_tree_cli.default)({
351
- l: depth,
352
- base: dir
380
+ import_node_fs.promises.stat(dirFullpath)
381
+ ];
382
+ case 1:
383
+ dirStat = _state.sent();
384
+ if (!(dirStat.isDirectory() && currentDepth < depth)) return [
385
+ 3,
386
+ 6
387
+ ];
388
+ _loop = function(i) {
389
+ var dirent, isLast, branchingSymbol, verticalSymbol, pathToDirectory, treeLinesForSubDirectory;
390
+ return _ts_generator(this, function(_state) {
391
+ switch(_state.label){
392
+ case 0:
393
+ dirent = childDirents[i];
394
+ isLast = i === childDirents.length - 1;
395
+ branchingSymbol = isLast ? SYMBOLS.LAST_BRANCH : SYMBOLS.BRANCH;
396
+ verticalSymbol = isLast ? SYMBOLS.INDENT : SYMBOLS.VERTICAL;
397
+ if (!dirent.isFile()) return [
398
+ 3,
399
+ 1
400
+ ];
401
+ lines.push("".concat(branchingSymbol).concat(dirent.name));
402
+ return [
403
+ 3,
404
+ 3
405
+ ];
406
+ case 1:
407
+ pathToDirectory = import_node_path.default.join(dirFullpath, dirent.name);
408
+ return [
409
+ 4,
410
+ getTreeLines(pathToDirectory, depth, currentDepth + 1)
411
+ ];
412
+ case 2:
413
+ treeLinesForSubDirectory = _state.sent();
414
+ lines = lines.concat(treeLinesForSubDirectory.map(function(line, index) {
415
+ return index === 0 ? "".concat(branchingSymbol).concat(line) : "".concat(verticalSymbol).concat(line);
416
+ }));
417
+ _state.label = 3;
418
+ case 3:
419
+ return [
420
+ 2
421
+ ];
422
+ }
423
+ });
424
+ };
425
+ return [
426
+ 4,
427
+ import_node_fs.promises.readdir(dirFullpath, {
428
+ withFileTypes: true
353
429
  })
354
430
  ];
431
+ case 2:
432
+ childDirents = _state.sent();
433
+ childDirents.sort(function(a, b) {
434
+ if (a.isDirectory() && b.isFile()) {
435
+ return -1;
436
+ } else if (a.isFile() && b.isDirectory()) {
437
+ return 1;
438
+ }
439
+ return b.name > a.name ? -1 : 1;
440
+ });
441
+ i = 0;
442
+ _state.label = 3;
443
+ case 3:
444
+ if (!(i < childDirents.length)) return [
445
+ 3,
446
+ 6
447
+ ];
448
+ return [
449
+ 5,
450
+ _ts_values(_loop(i))
451
+ ];
452
+ case 4:
453
+ _state.sent();
454
+ _state.label = 5;
455
+ case 5:
456
+ i++;
457
+ return [
458
+ 3,
459
+ 3
460
+ ];
461
+ case 6:
462
+ return [
463
+ 2,
464
+ lines
465
+ ];
466
+ }
467
+ });
468
+ });
469
+ return function getTreeLines(dirPath, depth) {
470
+ return _ref.apply(this, arguments);
471
+ };
472
+ }();
473
+ var tree = function() {
474
+ var _ref = _async_to_generator(function(dirPath, depth) {
475
+ var lines;
476
+ return _ts_generator(this, function(_state) {
477
+ switch(_state.label){
478
+ case 0:
479
+ return [
480
+ 4,
481
+ getTreeLines(dirPath, depth)
482
+ ];
355
483
  case 1:
356
- report = _state.sent().report;
484
+ lines = _state.sent();
357
485
  return [
358
486
  2,
359
- report
487
+ lines.join(import_node_os.default.EOL)
360
488
  ];
361
489
  }
362
490
  });
363
491
  });
364
- return function tree(dir, depth) {
492
+ return function tree(dirPath, depth) {
365
493
  return _ref.apply(this, arguments);
366
494
  };
367
495
  }();
368
496
  // src/cli/utils/preview/setup-hot-reloading.ts
369
- var import_node_path = __toESM(require("path"));
497
+ var import_node_path2 = __toESM(require("path"));
370
498
  var import_socket = require("socket.io");
371
499
  var import_chokidar = require("chokidar");
372
500
  var import_debounce = __toESM(require("debounce"));
@@ -383,7 +511,7 @@ var setupHotreloading = function(devServer2, emailDirRelativePath) {
383
511
  });
384
512
  var watcher = (0, import_chokidar.watch)(emailDirRelativePath, {
385
513
  ignoreInitial: true,
386
- cwd: import_node_path.default.resolve(process.cwd()),
514
+ cwd: import_node_path2.default.resolve(process.cwd()),
387
515
  // eslint-disable-next-line prefer-named-capture-group
388
516
  ignored: /(^|[/\\])\../
389
517
  });
@@ -400,7 +528,7 @@ var setupHotreloading = function(devServer2, emailDirRelativePath) {
400
528
  changes = [];
401
529
  }, 150);
402
530
  watcher.on("all", function(event, filename) {
403
- var file = filename.split(import_node_path.default.sep);
531
+ var file = filename.split(import_node_path2.default.sep);
404
532
  if (file.length === 0) {
405
533
  return;
406
534
  }
@@ -413,7 +541,7 @@ var setupHotreloading = function(devServer2, emailDirRelativePath) {
413
541
  return watcher;
414
542
  };
415
543
  // src/cli/utils/preview/start-dev-server.ts
416
- var import_node_path3 = __toESM(require("path"));
544
+ var import_node_path4 = __toESM(require("path"));
417
545
  var import_node_http = __toESM(require("http"));
418
546
  var import_node_url = __toESM(require("url"));
419
547
  var import_next = __toESM(require("next"));
@@ -427,8 +555,8 @@ var closeOraOnSIGNIT = function(spinner) {
427
555
  });
428
556
  };
429
557
  // src/cli/utils/preview/serve-static-file.ts
430
- var import_node_path2 = __toESM(require("path"));
431
- var import_node_fs = require("fs");
558
+ var import_node_path3 = __toESM(require("path"));
559
+ var import_node_fs2 = require("fs");
432
560
  var import_mime_types = require("mime-types");
433
561
  var serveStaticFile = function() {
434
562
  var _ref = _async_to_generator(function(res, parsedUrl, staticDirRelativePath) {
@@ -436,11 +564,11 @@ var serveStaticFile = function() {
436
564
  return _ts_generator(this, function(_state) {
437
565
  switch(_state.label){
438
566
  case 0:
439
- staticBaseDir = import_node_path2.default.join(process.cwd(), staticDirRelativePath);
567
+ staticBaseDir = import_node_path3.default.join(process.cwd(), staticDirRelativePath);
440
568
  pathname = parsedUrl.pathname;
441
- ext = import_node_path2.default.parse(pathname).ext;
442
- fileAbsolutePath = import_node_path2.default.join(staticBaseDir, pathname);
443
- doesFileExist = (0, import_node_fs.existsSync)(fileAbsolutePath);
569
+ ext = import_node_path3.default.parse(pathname).ext;
570
+ fileAbsolutePath = import_node_path3.default.join(staticBaseDir, pathname);
571
+ doesFileExist = (0, import_node_fs2.existsSync)(fileAbsolutePath);
444
572
  if (!!doesFileExist) return [
445
573
  3,
446
574
  1
@@ -454,7 +582,7 @@ var serveStaticFile = function() {
454
582
  case 1:
455
583
  return [
456
584
  4,
457
- import_node_fs.promises.stat(fileAbsolutePath)
585
+ import_node_fs2.promises.stat(fileAbsolutePath)
458
586
  ];
459
587
  case 2:
460
588
  fileStat = _state.sent();
@@ -463,7 +591,7 @@ var serveStaticFile = function() {
463
591
  }
464
592
  return [
465
593
  4,
466
- import_node_fs.promises.readFile(fileAbsolutePath)
594
+ import_node_fs2.promises.readFile(fileAbsolutePath)
467
595
  ];
468
596
  case 3:
469
597
  fileData = _state.sent();
@@ -509,8 +637,8 @@ var safeAsyncServerListen = function(server, port) {
509
637
  });
510
638
  });
511
639
  };
512
- var isRunningBuilt = __filename.endsWith(import_node_path3.default.join("cli", "index.js"));
513
- var cliPacakgeLocation = isRunningBuilt ? import_node_path3.default.resolve(__dirname, "..") : import_node_path3.default.resolve(__dirname, "../../../..");
640
+ var isRunningBuilt = __filename.endsWith(import_node_path4.default.join("cli", "index.js"));
641
+ var cliPacakgeLocation = isRunningBuilt ? import_node_path4.default.resolve(__dirname, "..") : import_node_path4.default.resolve(__dirname, "../../../..");
514
642
  var startDevServer = function() {
515
643
  var _ref = _async_to_generator(function(emailsDirRelativePath, staticBaseDirRelativePath, port) {
516
644
  var portAlreadyInUse, nextPortToTry, spinner, timeBeforeNextReady, app, isNextReady, nextReadyPromise, nextHandleRequest, secondsToNextReady;
@@ -585,7 +713,8 @@ var startDevServer = function() {
585
713
  }).start();
586
714
  closeOraOnSIGNIT(spinner);
587
715
  timeBeforeNextReady = performance.now();
588
- process.env = _object_spread({}, process.env, getEnvVariablesForPreviewApp(emailsDirRelativePath, cliPacakgeLocation, process.cwd()));
716
+ process.env = _object_spread({}, process.env, getEnvVariablesForPreviewApp(// If we don't do normalization here, stuff like https://github.com/resend/react-email/issues/1354 happens.
717
+ import_node_path4.default.normalize(emailsDirRelativePath), cliPacakgeLocation, process.cwd()));
589
718
  app = (0, import_next.default)({
590
719
  // passing in env here does not get the environment variables there
591
720
  dev: true,
@@ -664,7 +793,7 @@ var dev = function() {
664
793
  ,
665
794
  4
666
795
  ]);
667
- if (!import_node_fs2.default.existsSync(emailsDirRelativePath)) {
796
+ if (!import_node_fs3.default.existsSync(emailsDirRelativePath)) {
668
797
  throw new Error("Missing ".concat(emailsDirRelativePath, " folder"));
669
798
  }
670
799
  return [
@@ -699,8 +828,8 @@ var dev = function() {
699
828
  };
700
829
  }();
701
830
  // src/cli/commands/export.ts
702
- var import_node_fs4 = __toESM(require("fs"));
703
- var import_node_path5 = __toESM(require("path"));
831
+ var import_node_fs5 = __toESM(require("fs"));
832
+ var import_node_path6 = __toESM(require("path"));
704
833
  var import_glob = require("glob");
705
834
  var import_esbuild = require("esbuild");
706
835
  var import_ora2 = __toESM(require("ora"));
@@ -709,18 +838,18 @@ var import_render = require("@react-email/render");
709
838
  var import_normalize_path = __toESM(require("normalize-path"));
710
839
  var import_shelljs = require("shelljs");
711
840
  // src/actions/get-emails-directory-metadata.ts
712
- var import_node_fs3 = __toESM(require("fs"));
713
- var import_node_path4 = __toESM(require("path"));
841
+ var import_node_fs4 = __toESM(require("fs"));
842
+ var import_node_path5 = __toESM(require("path"));
714
843
  var isFileAnEmail = function(fullPath) {
715
- var stat = import_node_fs3.default.statSync(fullPath);
844
+ var stat = import_node_fs4.default.statSync(fullPath);
716
845
  if (stat.isDirectory()) return false;
717
- var ext = import_node_path4.default.parse(fullPath).ext;
846
+ var ext = import_node_path5.default.parse(fullPath).ext;
718
847
  if (![
719
848
  ".js",
720
849
  ".tsx",
721
850
  ".jsx"
722
851
  ].includes(ext)) return false;
723
- var fileContents = import_node_fs3.default.readFileSync(fullPath, "utf8");
852
+ var fileContents = import_node_fs4.default.readFileSync(fullPath, "utf8");
724
853
  return /\bexport\s+default\b/gm.test(fileContents);
725
854
  };
726
855
  var mergeDirectoriesWithSubDirectories = function(emailsDirectoryMetadata) {
@@ -731,7 +860,7 @@ var mergeDirectoriesWithSubDirectories = function(emailsDirectoryMetadata) {
731
860
  subDirectories: onlySubDirectory.subDirectories,
732
861
  emailFilenames: onlySubDirectory.emailFilenames,
733
862
  absolutePath: onlySubDirectory.absolutePath,
734
- directoryName: import_node_path4.default.join(currentResultingMergedDirectory.directoryName, onlySubDirectory.directoryName)
863
+ directoryName: import_node_path5.default.join(currentResultingMergedDirectory.directoryName, onlySubDirectory.directoryName)
735
864
  };
736
865
  }
737
866
  return currentResultingMergedDirectory;
@@ -742,28 +871,28 @@ var getEmailsDirectoryMetadata = function() {
742
871
  return _ts_generator(this, function(_state) {
743
872
  switch(_state.label){
744
873
  case 0:
745
- if (!import_node_fs3.default.existsSync(absolutePathToEmailsDirectory)) return [
874
+ if (!import_node_fs4.default.existsSync(absolutePathToEmailsDirectory)) return [
746
875
  2
747
876
  ];
748
877
  return [
749
878
  4,
750
- import_node_fs3.default.promises.readdir(absolutePathToEmailsDirectory, {
879
+ import_node_fs4.default.promises.readdir(absolutePathToEmailsDirectory, {
751
880
  withFileTypes: true
752
881
  })
753
882
  ];
754
883
  case 1:
755
884
  dirents = _state.sent();
756
885
  emailFilenames = dirents.filter(function(dirent) {
757
- return isFileAnEmail(import_node_path4.default.join(absolutePathToEmailsDirectory, dirent.name));
886
+ return isFileAnEmail(import_node_path5.default.join(absolutePathToEmailsDirectory, dirent.name));
758
887
  }).map(function(dirent) {
759
- return dirent.name.replace(import_node_path4.default.extname(dirent.name), "");
888
+ return dirent.name.replace(import_node_path5.default.extname(dirent.name), "");
760
889
  });
761
890
  return [
762
891
  4,
763
892
  Promise.all(dirents.filter(function(dirent) {
764
893
  return dirent.isDirectory() && !dirent.name.startsWith("_") && dirent.name !== "static";
765
894
  }).map(function(dirent) {
766
- return getEmailsDirectoryMetadata(import_node_path4.default.join(absolutePathToEmailsDirectory, dirent.name));
895
+ return getEmailsDirectoryMetadata(import_node_path5.default.join(absolutePathToEmailsDirectory, dirent.name));
767
896
  }))
768
897
  ];
769
898
  case 2:
@@ -772,7 +901,7 @@ var getEmailsDirectoryMetadata = function() {
772
901
  2,
773
902
  mergeDirectoriesWithSubDirectories({
774
903
  absolutePath: absolutePathToEmailsDirectory,
775
- directoryName: absolutePathToEmailsDirectory.split(import_node_path4.default.sep).pop(),
904
+ directoryName: absolutePathToEmailsDirectory.split(import_node_path5.default.sep).pop(),
776
905
  emailFilenames: emailFilenames,
777
906
  subDirectories: subDirectories
778
907
  })
@@ -788,7 +917,7 @@ var getEmailsDirectoryMetadata = function() {
788
917
  var getEmailTemplatesFromDirectory = function(emailDirectory) {
789
918
  var templatePaths = [];
790
919
  emailDirectory.emailFilenames.forEach(function(filename) {
791
- return templatePaths.push(import_node_path5.default.join(emailDirectory.absolutePath, filename));
920
+ return templatePaths.push(import_node_path6.default.join(emailDirectory.absolutePath, filename));
792
921
  });
793
922
  emailDirectory.subDirectories.forEach(function(directory) {
794
923
  var _templatePaths;
@@ -806,7 +935,7 @@ var exportTemplates = function() {
806
935
  closeOraOnSIGNIT(spinner);
807
936
  return [
808
937
  4,
809
- getEmailsDirectoryMetadata(import_node_path5.default.join(process.cwd(), emailsDirectoryPath))
938
+ getEmailsDirectoryMetadata(import_node_path6.default.join(process.cwd(), emailsDirectoryPath))
810
939
  ];
811
940
  case 1:
812
941
  emailsDirectoryMetadata = _state.sent();
@@ -863,8 +992,8 @@ var exportTemplates = function() {
863
992
  component = require(template);
864
993
  rendered = (0, import_render.render)(component.default({}), options);
865
994
  htmlPath = template.replace(".cjs", options.plainText ? ".txt" : ".html");
866
- (0, import_node_fs4.writeFileSync)(htmlPath, rendered);
867
- (0, import_node_fs4.unlinkSync)(template);
995
+ (0, import_node_fs5.writeFileSync)(htmlPath, rendered);
996
+ (0, import_node_fs5.unlinkSync)(template);
868
997
  } catch (exception) {
869
998
  spinner.stopAndPersist({
870
999
  symbol: import_log_symbols2.default.error,
@@ -891,19 +1020,19 @@ var exportTemplates = function() {
891
1020
  spinner.succeed("Rendered all files");
892
1021
  spinner.text = "Copying static files";
893
1022
  spinner.render();
894
- staticDirectoryPath = import_node_path5.default.join(emailsDirectoryPath, "static");
895
- if (!import_node_fs4.default.existsSync(staticDirectoryPath)) return [
1023
+ staticDirectoryPath = import_node_path6.default.join(emailsDirectoryPath, "static");
1024
+ if (!import_node_fs5.default.existsSync(staticDirectoryPath)) return [
896
1025
  3,
897
1026
  4
898
1027
  ];
899
- pathToDumpStaticFilesInto = import_node_path5.default.join(pathToWhereEmailMarkupShouldBeDumped, "static");
900
- if (!import_node_fs4.default.existsSync(pathToDumpStaticFilesInto)) return [
1028
+ pathToDumpStaticFilesInto = import_node_path6.default.join(pathToWhereEmailMarkupShouldBeDumped, "static");
1029
+ if (!import_node_fs5.default.existsSync(pathToDumpStaticFilesInto)) return [
901
1030
  3,
902
1031
  3
903
1032
  ];
904
1033
  return [
905
1034
  4,
906
- import_node_fs4.default.promises.rm(pathToDumpStaticFilesInto, {
1035
+ import_node_fs5.default.promises.rm(pathToDumpStaticFilesInto, {
907
1036
  recursive: true
908
1037
  })
909
1038
  ];
@@ -911,7 +1040,7 @@ var exportTemplates = function() {
911
1040
  _state.sent();
912
1041
  _state.label = 3;
913
1042
  case 3:
914
- result = (0, import_shelljs.cp)("-r", staticDirectoryPath, import_node_path5.default.join(pathToWhereEmailMarkupShouldBeDumped, "static"));
1043
+ result = (0, import_shelljs.cp)("-r", staticDirectoryPath, import_node_path6.default.join(pathToWhereEmailMarkupShouldBeDumped, "static"));
915
1044
  if (result.code > 0) {
916
1045
  spinner.stopAndPersist({
917
1046
  symbol: import_log_symbols2.default.error,
@@ -945,8 +1074,8 @@ var exportTemplates = function() {
945
1074
  };
946
1075
  }();
947
1076
  // src/cli/commands/build.ts
948
- var import_node_fs5 = __toESM(require("fs"));
949
- var import_node_path6 = __toESM(require("path"));
1077
+ var import_node_fs6 = __toESM(require("fs"));
1078
+ var import_node_path7 = __toESM(require("path"));
950
1079
  var import_ora3 = __toESM(require("ora"));
951
1080
  var import_shelljs2 = __toESM(require("shelljs"));
952
1081
  var import_node_child_process = require("child_process");
@@ -980,13 +1109,14 @@ var setNextEnvironmentVariablesForBuild = function() {
980
1109
  return _ts_generator(this, function(_state) {
981
1110
  switch(_state.label){
982
1111
  case 0:
983
- envVariables = _object_spread_props(_object_spread({}, getEnvVariablesForPreviewApp(emailsDirRelativePath, "PLACEHOLDER", "PLACEHOLDER")), {
1112
+ envVariables = _object_spread_props(_object_spread({}, getEnvVariablesForPreviewApp(// If we don't do normalization here, stuff like https://github.com/resend/react-email/issues/1354 happens.
1113
+ import_node_path7.default.normalize(emailsDirRelativePath), "PLACEHOLDER", "PLACEHOLDER")), {
984
1114
  NEXT_PUBLIC_IS_BUILDING: "true"
985
1115
  });
986
1116
  nextConfigContents = "\nconst path = require('path');\n/** @type {import('next').NextConfig} */\nmodule.exports = {\n env: {\n ...".concat(JSON.stringify(envVariables), ",\n NEXT_PUBLIC_USER_PROJECT_LOCATION: path.resolve(process.cwd(), '../'),\n NEXT_PUBLIC_CLI_PACKAGE_LOCATION: process.cwd(),\n },\n // this is needed so that the code for building emails works properly\n webpack: (\n /** @type {import('webpack').Configuration & { externals: string[] }} */\n config,\n { isServer }\n ) => {\n if (isServer) {\n config.externals.push('esbuild');\n }\n\n return config;\n },\n typescript: {\n ignoreBuildErrors: true\n },\n eslint: {\n ignoreDuringBuilds: true\n },\n experimental: {\n webpackBuildWorker: true,\n serverComponentsExternalPackages: [\n '@react-email/components',\n '@react-email/render',\n '@react-email/tailwind',\n ],\n },\n}");
987
1117
  return [
988
1118
  4,
989
- import_node_fs5.default.promises.writeFile(import_node_path6.default.resolve(builtPreviewAppPath, "./next.config.js"), nextConfigContents, "utf8")
1119
+ import_node_fs6.default.promises.writeFile(import_node_path7.default.resolve(builtPreviewAppPath, "./next.config.js"), nextConfigContents, "utf8")
990
1120
  ];
991
1121
  case 1:
992
1122
  _state.sent();
@@ -1004,7 +1134,7 @@ var getEmailSlugsFromEmailDirectory = function(emailDirectory, emailsDirectoryAb
1004
1134
  var directoryPathRelativeToEmailsDirectory = emailDirectory.absolutePath.replace(emailsDirectoryAbsolutePath, "").trim();
1005
1135
  var slugs = [];
1006
1136
  emailDirectory.emailFilenames.forEach(function(filename) {
1007
- return slugs.push(import_node_path6.default.join(directoryPathRelativeToEmailsDirectory, filename).split(import_node_path6.default.sep).filter(function(segment) {
1137
+ return slugs.push(import_node_path7.default.join(directoryPathRelativeToEmailsDirectory, filename).split(import_node_path7.default.sep).filter(function(segment) {
1008
1138
  return segment.length > 0;
1009
1139
  }));
1010
1140
  });
@@ -1034,7 +1164,7 @@ var forceSSGForEmailPreviews = function() {
1034
1164
  });
1035
1165
  return [
1036
1166
  4,
1037
- import_node_fs5.default.promises.appendFile(import_node_path6.default.resolve(builtPreviewAppPath, "./src/app/preview/[...slug]/page.tsx"), "\n\nexport async function generateStaticParams() { \n return ".concat(JSON.stringify(parameters), ";\n}"), "utf8")
1167
+ import_node_fs6.default.promises.appendFile(import_node_path7.default.resolve(builtPreviewAppPath, "./src/app/preview/[...slug]/page.tsx"), "\n\nexport async function generateStaticParams() { \n return ".concat(JSON.stringify(parameters), ";\n}"), "utf8")
1038
1168
  ];
1039
1169
  case 2:
1040
1170
  _state.sent();
@@ -1054,11 +1184,11 @@ var updatePackageJson = function() {
1054
1184
  return _ts_generator(this, function(_state) {
1055
1185
  switch(_state.label){
1056
1186
  case 0:
1057
- packageJsonPath = import_node_path6.default.resolve(builtPreviewAppPath, "./package.json");
1187
+ packageJsonPath = import_node_path7.default.resolve(builtPreviewAppPath, "./package.json");
1058
1188
  _ = JSON.parse;
1059
1189
  return [
1060
1190
  4,
1061
- import_node_fs5.default.promises.readFile(packageJsonPath, "utf8")
1191
+ import_node_fs6.default.promises.readFile(packageJsonPath, "utf8")
1062
1192
  ];
1063
1193
  case 1:
1064
1194
  packageJson = _.apply(JSON, [
@@ -1069,7 +1199,7 @@ var updatePackageJson = function() {
1069
1199
  packageJson.dependencies.sharp = "0.33.2";
1070
1200
  return [
1071
1201
  4,
1072
- import_node_fs5.default.promises.writeFile(packageJsonPath, JSON.stringify(packageJson), "utf8")
1202
+ import_node_fs6.default.promises.writeFile(packageJsonPath, JSON.stringify(packageJson), "utf8")
1073
1203
  ];
1074
1204
  case 2:
1075
1205
  _state.sent();
@@ -1127,20 +1257,20 @@ var build = function() {
1127
1257
  }).start();
1128
1258
  closeOraOnSIGNIT(spinner);
1129
1259
  spinner.text = "Checking if emails folder exists";
1130
- if (!import_node_fs5.default.existsSync(emailsDirRelativePath)) {
1260
+ if (!import_node_fs6.default.existsSync(emailsDirRelativePath)) {
1131
1261
  throw new Error("Missing ".concat(emailsDirRelativePath, " folder"));
1132
1262
  }
1133
- emailsDirPath = import_node_path6.default.join(process.cwd(), emailsDirRelativePath);
1134
- staticPath = import_node_path6.default.join(emailsDirPath, "static");
1135
- builtPreviewAppPath = import_node_path6.default.join(process.cwd(), ".react-email");
1136
- if (!import_node_fs5.default.existsSync(builtPreviewAppPath)) return [
1263
+ emailsDirPath = import_node_path7.default.join(process.cwd(), emailsDirRelativePath);
1264
+ staticPath = import_node_path7.default.join(emailsDirPath, "static");
1265
+ builtPreviewAppPath = import_node_path7.default.join(process.cwd(), ".react-email");
1266
+ if (!import_node_fs6.default.existsSync(builtPreviewAppPath)) return [
1137
1267
  3,
1138
1268
  3
1139
1269
  ];
1140
1270
  spinner.text = "Deleting pre-existing `.react-email` folder";
1141
1271
  return [
1142
1272
  4,
1143
- import_node_fs5.default.promises.rm(builtPreviewAppPath, {
1273
+ import_node_fs6.default.promises.rm(builtPreviewAppPath, {
1144
1274
  recursive: true
1145
1275
  })
1146
1276
  ];
@@ -1151,7 +1281,7 @@ var build = function() {
1151
1281
  spinner.text = "Copying preview app from CLI to `.react-email`";
1152
1282
  return [
1153
1283
  4,
1154
- import_node_fs5.default.promises.cp(cliPacakgeLocation, builtPreviewAppPath, {
1284
+ import_node_fs6.default.promises.cp(cliPacakgeLocation, builtPreviewAppPath, {
1155
1285
  recursive: true,
1156
1286
  filter: function(source) {
1157
1287
  return !source.includes("/cli/") && !source.includes("/.next/") && !/\/node_modules\/?$/.test(source);
@@ -1160,15 +1290,15 @@ var build = function() {
1160
1290
  ];
1161
1291
  case 4:
1162
1292
  _state.sent();
1163
- if (!import_node_fs5.default.existsSync(staticPath)) return [
1293
+ if (!import_node_fs6.default.existsSync(staticPath)) return [
1164
1294
  3,
1165
1295
  6
1166
1296
  ];
1167
1297
  spinner.text = "Copying `static` folder into `.react-email/public/static`";
1168
- builtStaticDirectory = import_node_path6.default.resolve(builtPreviewAppPath, "./public/static");
1298
+ builtStaticDirectory = import_node_path7.default.resolve(builtPreviewAppPath, "./public/static");
1169
1299
  return [
1170
1300
  4,
1171
- import_node_fs5.default.promises.cp(staticPath, builtStaticDirectory, {
1301
+ import_node_fs6.default.promises.cp(staticPath, builtStaticDirectory, {
1172
1302
  recursive: true
1173
1303
  })
1174
1304
  ];
@@ -1238,8 +1368,8 @@ var build = function() {
1238
1368
  };
1239
1369
  }();
1240
1370
  // src/cli/commands/start.ts
1241
- var import_node_fs6 = __toESM(require("fs"));
1242
- var import_node_path7 = __toESM(require("path"));
1371
+ var import_node_fs7 = __toESM(require("fs"));
1372
+ var import_node_path8 = __toESM(require("path"));
1243
1373
  var import_node_child_process2 = require("child_process");
1244
1374
  var start = function() {
1245
1375
  var _ref = _async_to_generator(function() {
@@ -1247,8 +1377,8 @@ var start = function() {
1247
1377
  return _ts_generator(this, function(_state) {
1248
1378
  try {
1249
1379
  usersProjectLocation = process.cwd();
1250
- builtPreviewPath = import_node_path7.default.resolve(usersProjectLocation, "./.react-email");
1251
- if (!import_node_fs6.default.existsSync(builtPreviewPath)) {
1380
+ builtPreviewPath = import_node_path8.default.resolve(usersProjectLocation, "./.react-email");
1381
+ if (!import_node_fs7.default.existsSync(builtPreviewPath)) {
1252
1382
  throw new Error("Could not find `.react-email`, maybe you haven't ran `email build`?");
1253
1383
  }
1254
1384
  nextStart = (0, import_node_child_process2.spawn)("npm", [
package/cli/index.mjs CHANGED
@@ -13,7 +13,7 @@ import { program } from "commander";
13
13
  // package.json
14
14
  var package_default = {
15
15
  name: "react-email",
16
- version: "2.1.0",
16
+ version: "2.1.1-canary.1",
17
17
  description: "A live preview of your emails right in your browser.",
18
18
  bin: {
19
19
  email: "./cli/index.js"
@@ -41,11 +41,11 @@ var package_default = {
41
41
  dependencies: {
42
42
  "@radix-ui/colors": "1.0.1",
43
43
  "@radix-ui/react-collapsible": "1.0.3",
44
- "@radix-ui/react-popover": "1.0.6",
44
+ "@radix-ui/react-popover": "1.0.7",
45
45
  "@radix-ui/react-slot": "1.0.2",
46
46
  "@radix-ui/react-toggle-group": "1.0.4",
47
47
  "@radix-ui/react-tooltip": "1.0.6",
48
- "@react-email/components": "0.0.15",
48
+ "@react-email/components": "0.0.16-canary.1",
49
49
  "@react-email/render": "0.0.12",
50
50
  "@swc/core": "1.3.101",
51
51
  "@types/react": "^18.2.0",
@@ -79,7 +79,6 @@ var package_default = {
79
79
  "stacktrace-parser": "0.1.10",
80
80
  "tailwind-merge": "2.2.0",
81
81
  tailwindcss: "3.4.0",
82
- "tree-cli": "0.6.7",
83
82
  typescript: "5.1.6"
84
83
  },
85
84
  devDependencies: {
@@ -91,27 +90,73 @@ var package_default = {
91
90
  "@vercel/style-guide": "5.1.0",
92
91
  eslint: "8.50.0",
93
92
  tsup: "7.2.0",
94
- tsx: "4.7.0",
93
+ tsx: "4.7.1",
95
94
  vitest: "1.1.3",
96
95
  watch: "1.0.2"
97
96
  }
98
97
  };
99
98
 
100
99
  // src/cli/commands/dev.ts
101
- import fs2 from "fs";
100
+ import fs3 from "fs";
102
101
 
103
102
  // src/cli/utils/tree.ts
104
- import treeCli from "tree-cli";
105
- var tree = async (dir, depth) => {
106
- const { report } = await treeCli({
107
- l: depth,
108
- base: dir
109
- });
110
- return report;
103
+ import { promises as fs } from "fs";
104
+ import os from "os";
105
+ import path from "path";
106
+ var SYMBOLS = {
107
+ BRANCH: "\u251C\u2500\u2500 ",
108
+ EMPTY: "",
109
+ INDENT: " ",
110
+ LAST_BRANCH: "\u2514\u2500\u2500 ",
111
+ VERTICAL: "\u2502 "
112
+ };
113
+ var getTreeLines = async (dirPath, depth, currentDepth = 0) => {
114
+ const base = process.cwd();
115
+ const dirFullpath = path.resolve(base, dirPath);
116
+ const dirname = path.basename(dirFullpath);
117
+ let lines = [dirname];
118
+ const dirStat = await fs.stat(dirFullpath);
119
+ if (dirStat.isDirectory() && currentDepth < depth) {
120
+ const childDirents = await fs.readdir(dirFullpath, { withFileTypes: true });
121
+ childDirents.sort((a, b) => {
122
+ if (a.isDirectory() && b.isFile()) {
123
+ return -1;
124
+ } else if (a.isFile() && b.isDirectory()) {
125
+ return 1;
126
+ }
127
+ return b.name > a.name ? -1 : 1;
128
+ });
129
+ for (let i = 0; i < childDirents.length; i++) {
130
+ const dirent = childDirents[i];
131
+ const isLast = i === childDirents.length - 1;
132
+ const branchingSymbol = isLast ? SYMBOLS.LAST_BRANCH : SYMBOLS.BRANCH;
133
+ const verticalSymbol = isLast ? SYMBOLS.INDENT : SYMBOLS.VERTICAL;
134
+ if (dirent.isFile()) {
135
+ lines.push(`${branchingSymbol}${dirent.name}`);
136
+ } else {
137
+ const pathToDirectory = path.join(dirFullpath, dirent.name);
138
+ const treeLinesForSubDirectory = await getTreeLines(
139
+ pathToDirectory,
140
+ depth,
141
+ currentDepth + 1
142
+ );
143
+ lines = lines.concat(
144
+ treeLinesForSubDirectory.map(
145
+ (line, index) => index === 0 ? `${branchingSymbol}${line}` : `${verticalSymbol}${line}`
146
+ )
147
+ );
148
+ }
149
+ }
150
+ }
151
+ return lines;
152
+ };
153
+ var tree = async (dirPath, depth) => {
154
+ const lines = await getTreeLines(dirPath, depth);
155
+ return lines.join(os.EOL);
111
156
  };
112
157
 
113
158
  // src/cli/utils/preview/setup-hot-reloading.ts
114
- import path from "path";
159
+ import path2 from "path";
115
160
  import { Server as SocketServer } from "socket.io";
116
161
  import { watch } from "chokidar";
117
162
  import debounce from "debounce";
@@ -126,7 +171,7 @@ var setupHotreloading = (devServer2, emailDirRelativePath) => {
126
171
  });
127
172
  const watcher = watch(emailDirRelativePath, {
128
173
  ignoreInitial: true,
129
- cwd: path.resolve(process.cwd()),
174
+ cwd: path2.resolve(process.cwd()),
130
175
  // eslint-disable-next-line prefer-named-capture-group
131
176
  ignored: /(^|[/\\])\../
132
177
  });
@@ -143,7 +188,7 @@ var setupHotreloading = (devServer2, emailDirRelativePath) => {
143
188
  changes = [];
144
189
  }, 150);
145
190
  watcher.on("all", (event, filename) => {
146
- const file = filename.split(path.sep);
191
+ const file = filename.split(path2.sep);
147
192
  if (file.length === 0) {
148
193
  return;
149
194
  }
@@ -157,7 +202,7 @@ var setupHotreloading = (devServer2, emailDirRelativePath) => {
157
202
  };
158
203
 
159
204
  // src/cli/utils/preview/start-dev-server.ts
160
- import path4 from "path";
205
+ import path5 from "path";
161
206
  import http from "http";
162
207
  import url from "url";
163
208
  import next from "next";
@@ -173,36 +218,36 @@ var closeOraOnSIGNIT = (spinner) => {
173
218
  };
174
219
 
175
220
  // src/cli/utils/preview/serve-static-file.ts
176
- import path2 from "path";
177
- import { promises as fs, existsSync } from "fs";
221
+ import path3 from "path";
222
+ import { promises as fs2, existsSync } from "fs";
178
223
  import { lookup } from "mime-types";
179
224
  var serveStaticFile = async (res, parsedUrl, staticDirRelativePath) => {
180
- const staticBaseDir = path2.join(process.cwd(), staticDirRelativePath);
225
+ const staticBaseDir = path3.join(process.cwd(), staticDirRelativePath);
181
226
  const pathname = parsedUrl.pathname;
182
- const ext = path2.parse(pathname).ext;
183
- let fileAbsolutePath = path2.join(staticBaseDir, pathname);
227
+ const ext = path3.parse(pathname).ext;
228
+ let fileAbsolutePath = path3.join(staticBaseDir, pathname);
184
229
  const doesFileExist = existsSync(fileAbsolutePath);
185
230
  if (!doesFileExist) {
186
231
  res.statusCode = 404;
187
232
  res.end(`File ${pathname} not found!`);
188
233
  } else {
189
- const fileStat = await fs.stat(fileAbsolutePath);
234
+ const fileStat = await fs2.stat(fileAbsolutePath);
190
235
  if (fileStat.isDirectory()) {
191
236
  fileAbsolutePath += `/index${ext}`;
192
237
  }
193
- const fileData = await fs.readFile(fileAbsolutePath);
238
+ const fileData = await fs2.readFile(fileAbsolutePath);
194
239
  res.setHeader("Content-type", lookup(ext) || "text/plain");
195
240
  res.end(fileData);
196
241
  }
197
242
  };
198
243
 
199
244
  // src/cli/utils/preview/get-env-variables-for-preview-app.ts
200
- import path3 from "path";
245
+ import path4 from "path";
201
246
  var getEnvVariablesForPreviewApp = (relativePathToEmailsDirectory, cliPackageLocation, cwd) => {
202
247
  return {
203
248
  NEXT_PUBLIC_EMAILS_DIR_RELATIVE_PATH: relativePathToEmailsDirectory,
204
249
  NEXT_PUBLIC_CLI_PACKAGE_LOCATION: cliPackageLocation,
205
- NEXT_PUBLIC_OS_PATH_SEPARATOR: path3.sep,
250
+ NEXT_PUBLIC_OS_PATH_SEPARATOR: path4.sep,
206
251
  NEXT_PUBLIC_USER_PROJECT_LOCATION: cwd
207
252
  };
208
253
  };
@@ -221,8 +266,8 @@ var safeAsyncServerListen = (server, port) => {
221
266
  });
222
267
  });
223
268
  };
224
- var isRunningBuilt = __filename.endsWith(path4.join("cli", "index.js"));
225
- var cliPacakgeLocation = isRunningBuilt ? path4.resolve(__dirname, "..") : path4.resolve(__dirname, "../../../..");
269
+ var isRunningBuilt = __filename.endsWith(path5.join("cli", "index.js"));
270
+ var cliPacakgeLocation = isRunningBuilt ? path5.resolve(__dirname, "..") : path5.resolve(__dirname, "../../../..");
226
271
  var startDevServer = async (emailsDirRelativePath, staticBaseDirRelativePath, port) => {
227
272
  devServer = http.createServer((req, res) => {
228
273
  if (!req.url) {
@@ -287,7 +332,8 @@ var startDevServer = async (emailsDirRelativePath, staticBaseDirRelativePath, po
287
332
  process.env = {
288
333
  ...process.env,
289
334
  ...getEnvVariablesForPreviewApp(
290
- emailsDirRelativePath,
335
+ // If we don't do normalization here, stuff like https://github.com/resend/react-email/issues/1354 happens.
336
+ path5.normalize(emailsDirRelativePath),
291
337
  cliPacakgeLocation,
292
338
  process.cwd()
293
339
  )
@@ -343,7 +389,7 @@ process.on(
343
389
  // src/cli/commands/dev.ts
344
390
  var dev = async ({ dir: emailsDirRelativePath, port }) => {
345
391
  try {
346
- if (!fs2.existsSync(emailsDirRelativePath)) {
392
+ if (!fs3.existsSync(emailsDirRelativePath)) {
347
393
  throw new Error(`Missing ${emailsDirRelativePath} folder`);
348
394
  }
349
395
  const devServer2 = await startDevServer(
@@ -360,8 +406,8 @@ var dev = async ({ dir: emailsDirRelativePath, port }) => {
360
406
  };
361
407
 
362
408
  // src/cli/commands/export.ts
363
- import fs4, { unlinkSync, writeFileSync } from "fs";
364
- import path6 from "path";
409
+ import fs5, { unlinkSync, writeFileSync } from "fs";
410
+ import path7 from "path";
365
411
  import { glob } from "glob";
366
412
  import { buildSync } from "esbuild";
367
413
  import ora2 from "ora";
@@ -371,16 +417,16 @@ import normalize from "normalize-path";
371
417
  import { cp } from "shelljs";
372
418
 
373
419
  // src/actions/get-emails-directory-metadata.ts
374
- import fs3 from "fs";
375
- import path5 from "path";
420
+ import fs4 from "fs";
421
+ import path6 from "path";
376
422
  var isFileAnEmail = (fullPath) => {
377
- const stat = fs3.statSync(fullPath);
423
+ const stat = fs4.statSync(fullPath);
378
424
  if (stat.isDirectory())
379
425
  return false;
380
- const { ext } = path5.parse(fullPath);
426
+ const { ext } = path6.parse(fullPath);
381
427
  if (![".js", ".tsx", ".jsx"].includes(ext))
382
428
  return false;
383
- const fileContents = fs3.readFileSync(fullPath, "utf8");
429
+ const fileContents = fs4.readFileSync(fullPath, "utf8");
384
430
  return /\bexport\s+default\b/gm.test(fileContents);
385
431
  };
386
432
  var mergeDirectoriesWithSubDirectories = (emailsDirectoryMetadata) => {
@@ -391,7 +437,7 @@ var mergeDirectoriesWithSubDirectories = (emailsDirectoryMetadata) => {
391
437
  subDirectories: onlySubDirectory.subDirectories,
392
438
  emailFilenames: onlySubDirectory.emailFilenames,
393
439
  absolutePath: onlySubDirectory.absolutePath,
394
- directoryName: path5.join(
440
+ directoryName: path6.join(
395
441
  currentResultingMergedDirectory.directoryName,
396
442
  onlySubDirectory.directoryName
397
443
  )
@@ -400,26 +446,26 @@ var mergeDirectoriesWithSubDirectories = (emailsDirectoryMetadata) => {
400
446
  return currentResultingMergedDirectory;
401
447
  };
402
448
  var getEmailsDirectoryMetadata = async (absolutePathToEmailsDirectory) => {
403
- if (!fs3.existsSync(absolutePathToEmailsDirectory))
449
+ if (!fs4.existsSync(absolutePathToEmailsDirectory))
404
450
  return;
405
- const dirents = await fs3.promises.readdir(absolutePathToEmailsDirectory, {
451
+ const dirents = await fs4.promises.readdir(absolutePathToEmailsDirectory, {
406
452
  withFileTypes: true
407
453
  });
408
454
  const emailFilenames = dirents.filter(
409
- (dirent) => isFileAnEmail(path5.join(absolutePathToEmailsDirectory, dirent.name))
410
- ).map((dirent) => dirent.name.replace(path5.extname(dirent.name), ""));
455
+ (dirent) => isFileAnEmail(path6.join(absolutePathToEmailsDirectory, dirent.name))
456
+ ).map((dirent) => dirent.name.replace(path6.extname(dirent.name), ""));
411
457
  const subDirectories = await Promise.all(
412
458
  dirents.filter(
413
459
  (dirent) => dirent.isDirectory() && !dirent.name.startsWith("_") && dirent.name !== "static"
414
460
  ).map(
415
461
  (dirent) => getEmailsDirectoryMetadata(
416
- path5.join(absolutePathToEmailsDirectory, dirent.name)
462
+ path6.join(absolutePathToEmailsDirectory, dirent.name)
417
463
  )
418
464
  )
419
465
  );
420
466
  return mergeDirectoriesWithSubDirectories({
421
467
  absolutePath: absolutePathToEmailsDirectory,
422
- directoryName: absolutePathToEmailsDirectory.split(path5.sep).pop(),
468
+ directoryName: absolutePathToEmailsDirectory.split(path6.sep).pop(),
423
469
  emailFilenames,
424
470
  subDirectories
425
471
  });
@@ -429,7 +475,7 @@ var getEmailsDirectoryMetadata = async (absolutePathToEmailsDirectory) => {
429
475
  var getEmailTemplatesFromDirectory = (emailDirectory) => {
430
476
  const templatePaths = [];
431
477
  emailDirectory.emailFilenames.forEach(
432
- (filename) => templatePaths.push(path6.join(emailDirectory.absolutePath, filename))
478
+ (filename) => templatePaths.push(path7.join(emailDirectory.absolutePath, filename))
433
479
  );
434
480
  emailDirectory.subDirectories.forEach((directory) => {
435
481
  templatePaths.push(...getEmailTemplatesFromDirectory(directory));
@@ -440,7 +486,7 @@ var exportTemplates = async (pathToWhereEmailMarkupShouldBeDumped, emailsDirecto
440
486
  const spinner = ora2("Preparing files...\n").start();
441
487
  closeOraOnSIGNIT(spinner);
442
488
  const emailsDirectoryMetadata = await getEmailsDirectoryMetadata(
443
- path6.join(process.cwd(), emailsDirectoryPath)
489
+ path7.join(process.cwd(), emailsDirectoryPath)
444
490
  );
445
491
  if (typeof emailsDirectoryMetadata === "undefined") {
446
492
  spinner.stopAndPersist({
@@ -507,18 +553,18 @@ ${allTemplates.map((p) => `- ${p}`).join("\n")}`
507
553
  spinner.succeed("Rendered all files");
508
554
  spinner.text = `Copying static files`;
509
555
  spinner.render();
510
- const staticDirectoryPath = path6.join(emailsDirectoryPath, "static");
511
- if (fs4.existsSync(staticDirectoryPath)) {
512
- const pathToDumpStaticFilesInto = path6.join(
556
+ const staticDirectoryPath = path7.join(emailsDirectoryPath, "static");
557
+ if (fs5.existsSync(staticDirectoryPath)) {
558
+ const pathToDumpStaticFilesInto = path7.join(
513
559
  pathToWhereEmailMarkupShouldBeDumped,
514
560
  "static"
515
561
  );
516
- if (fs4.existsSync(pathToDumpStaticFilesInto))
517
- await fs4.promises.rm(pathToDumpStaticFilesInto, { recursive: true });
562
+ if (fs5.existsSync(pathToDumpStaticFilesInto))
563
+ await fs5.promises.rm(pathToDumpStaticFilesInto, { recursive: true });
518
564
  const result = cp(
519
565
  "-r",
520
566
  staticDirectoryPath,
521
- path6.join(pathToWhereEmailMarkupShouldBeDumped, "static")
567
+ path7.join(pathToWhereEmailMarkupShouldBeDumped, "static")
522
568
  );
523
569
  if (result.code > 0) {
524
570
  spinner.stopAndPersist({
@@ -541,8 +587,8 @@ ${allTemplates.map((p) => `- ${p}`).join("\n")}`
541
587
  };
542
588
 
543
589
  // src/cli/commands/build.ts
544
- import fs5 from "fs";
545
- import path7 from "path";
590
+ import fs6 from "fs";
591
+ import path8 from "path";
546
592
  import ora3 from "ora";
547
593
  import shell from "shelljs";
548
594
  import { spawn } from "child_process";
@@ -574,7 +620,8 @@ var buildPreviewApp = (absoluteDirectory) => {
574
620
  var setNextEnvironmentVariablesForBuild = async (emailsDirRelativePath, builtPreviewAppPath) => {
575
621
  const envVariables = {
576
622
  ...getEnvVariablesForPreviewApp(
577
- emailsDirRelativePath,
623
+ // If we don't do normalization here, stuff like https://github.com/resend/react-email/issues/1354 happens.
624
+ path8.normalize(emailsDirRelativePath),
578
625
  "PLACEHOLDER",
579
626
  "PLACEHOLDER"
580
627
  ),
@@ -616,8 +663,8 @@ module.exports = {
616
663
  ],
617
664
  },
618
665
  }`;
619
- await fs5.promises.writeFile(
620
- path7.resolve(builtPreviewAppPath, "./next.config.js"),
666
+ await fs6.promises.writeFile(
667
+ path8.resolve(builtPreviewAppPath, "./next.config.js"),
621
668
  nextConfigContents,
622
669
  "utf8"
623
670
  );
@@ -627,7 +674,7 @@ var getEmailSlugsFromEmailDirectory = (emailDirectory, emailsDirectoryAbsolutePa
627
674
  const slugs = [];
628
675
  emailDirectory.emailFilenames.forEach(
629
676
  (filename) => slugs.push(
630
- path7.join(directoryPathRelativeToEmailsDirectory, filename).split(path7.sep).filter((segment) => segment.length > 0)
677
+ path8.join(directoryPathRelativeToEmailsDirectory, filename).split(path8.sep).filter((segment) => segment.length > 0)
631
678
  )
632
679
  );
633
680
  emailDirectory.subDirectories.forEach((directory) => {
@@ -649,8 +696,8 @@ var forceSSGForEmailPreviews = async (emailsDirPath, builtPreviewAppPath) => {
649
696
  emailDirectoryMetadata,
650
697
  emailsDirPath
651
698
  ).map((slug) => ({ slug }));
652
- await fs5.promises.appendFile(
653
- path7.resolve(builtPreviewAppPath, "./src/app/preview/[...slug]/page.tsx"),
699
+ await fs6.promises.appendFile(
700
+ path8.resolve(builtPreviewAppPath, "./src/app/preview/[...slug]/page.tsx"),
654
701
  `
655
702
 
656
703
  export async function generateStaticParams() {
@@ -660,14 +707,14 @@ export async function generateStaticParams() {
660
707
  );
661
708
  };
662
709
  var updatePackageJson = async (builtPreviewAppPath) => {
663
- const packageJsonPath = path7.resolve(builtPreviewAppPath, "./package.json");
710
+ const packageJsonPath = path8.resolve(builtPreviewAppPath, "./package.json");
664
711
  const packageJson = JSON.parse(
665
- await fs5.promises.readFile(packageJsonPath, "utf8")
712
+ await fs6.promises.readFile(packageJsonPath, "utf8")
666
713
  );
667
714
  packageJson.scripts.build = "next build";
668
715
  packageJson.scripts.start = "next start";
669
716
  packageJson.dependencies.sharp = "0.33.2";
670
- await fs5.promises.writeFile(
717
+ await fs6.promises.writeFile(
671
718
  packageJsonPath,
672
719
  JSON.stringify(packageJson),
673
720
  "utf8"
@@ -703,30 +750,30 @@ var build = async ({
703
750
  }).start();
704
751
  closeOraOnSIGNIT(spinner);
705
752
  spinner.text = "Checking if emails folder exists";
706
- if (!fs5.existsSync(emailsDirRelativePath)) {
753
+ if (!fs6.existsSync(emailsDirRelativePath)) {
707
754
  throw new Error(`Missing ${emailsDirRelativePath} folder`);
708
755
  }
709
- const emailsDirPath = path7.join(process.cwd(), emailsDirRelativePath);
710
- const staticPath = path7.join(emailsDirPath, "static");
711
- const builtPreviewAppPath = path7.join(process.cwd(), ".react-email");
712
- if (fs5.existsSync(builtPreviewAppPath)) {
756
+ const emailsDirPath = path8.join(process.cwd(), emailsDirRelativePath);
757
+ const staticPath = path8.join(emailsDirPath, "static");
758
+ const builtPreviewAppPath = path8.join(process.cwd(), ".react-email");
759
+ if (fs6.existsSync(builtPreviewAppPath)) {
713
760
  spinner.text = "Deleting pre-existing `.react-email` folder";
714
- await fs5.promises.rm(builtPreviewAppPath, { recursive: true });
761
+ await fs6.promises.rm(builtPreviewAppPath, { recursive: true });
715
762
  }
716
763
  spinner.text = "Copying preview app from CLI to `.react-email`";
717
- await fs5.promises.cp(cliPacakgeLocation, builtPreviewAppPath, {
764
+ await fs6.promises.cp(cliPacakgeLocation, builtPreviewAppPath, {
718
765
  recursive: true,
719
766
  filter: (source) => {
720
767
  return !source.includes("/cli/") && !source.includes("/.next/") && !/\/node_modules\/?$/.test(source);
721
768
  }
722
769
  });
723
- if (fs5.existsSync(staticPath)) {
770
+ if (fs6.existsSync(staticPath)) {
724
771
  spinner.text = "Copying `static` folder into `.react-email/public/static`";
725
- const builtStaticDirectory = path7.resolve(
772
+ const builtStaticDirectory = path8.resolve(
726
773
  builtPreviewAppPath,
727
774
  "./public/static"
728
775
  );
729
- await fs5.promises.cp(staticPath, builtStaticDirectory, {
776
+ await fs6.promises.cp(staticPath, builtStaticDirectory, {
730
777
  recursive: true
731
778
  });
732
779
  }
@@ -753,17 +800,17 @@ var build = async ({
753
800
  };
754
801
 
755
802
  // src/cli/commands/start.ts
756
- import fs6 from "fs";
757
- import path8 from "path";
803
+ import fs7 from "fs";
804
+ import path9 from "path";
758
805
  import { spawn as spawn2 } from "child_process";
759
806
  var start = async () => {
760
807
  try {
761
808
  const usersProjectLocation = process.cwd();
762
- const builtPreviewPath = path8.resolve(
809
+ const builtPreviewPath = path9.resolve(
763
810
  usersProjectLocation,
764
811
  "./.react-email"
765
812
  );
766
- if (!fs6.existsSync(builtPreviewPath)) {
813
+ if (!fs7.existsSync(builtPreviewPath)) {
767
814
  throw new Error(
768
815
  "Could not find `.react-email`, maybe you haven't ran `email build`?"
769
816
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-email",
3
- "version": "2.1.0",
3
+ "version": "2.1.1-canary.1",
4
4
  "description": "A live preview of your emails right in your browser.",
5
5
  "bin": {
6
6
  "email": "./cli/index.js"
@@ -21,11 +21,11 @@
21
21
  "dependencies": {
22
22
  "@radix-ui/colors": "1.0.1",
23
23
  "@radix-ui/react-collapsible": "1.0.3",
24
- "@radix-ui/react-popover": "1.0.6",
24
+ "@radix-ui/react-popover": "1.0.7",
25
25
  "@radix-ui/react-slot": "1.0.2",
26
26
  "@radix-ui/react-toggle-group": "1.0.4",
27
27
  "@radix-ui/react-tooltip": "1.0.6",
28
- "@react-email/components": "0.0.15",
28
+ "@react-email/components": "0.0.16-canary.1",
29
29
  "@react-email/render": "0.0.12",
30
30
  "@swc/core": "1.3.101",
31
31
  "@types/react": "^18.2.0",
@@ -59,7 +59,6 @@
59
59
  "stacktrace-parser": "0.1.10",
60
60
  "tailwind-merge": "2.2.0",
61
61
  "tailwindcss": "3.4.0",
62
- "tree-cli": "0.6.7",
63
62
  "typescript": "5.1.6"
64
63
  },
65
64
  "devDependencies": {
@@ -71,7 +70,7 @@
71
70
  "@vercel/style-guide": "5.1.0",
72
71
  "eslint": "8.50.0",
73
72
  "tsup": "7.2.0",
74
- "tsx": "4.7.0",
73
+ "tsx": "4.7.1",
75
74
  "vitest": "1.1.3",
76
75
  "watch": "1.0.2"
77
76
  },
@@ -56,6 +56,12 @@ export const getEmailComponent = async (
56
56
  ...global,
57
57
  console,
58
58
  Buffer,
59
+ TextDecoder,
60
+ TextDecoderStream,
61
+ TextEncoder,
62
+ TextEncoderStream,
63
+ ReadableStream,
64
+ URL,
59
65
  module: { exports: { default: undefined as unknown } },
60
66
  __filanem: emailPath,
61
67
  __dirname: path.dirname(emailPath),