Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/remove-debounce.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"react-email": patch
---

Remove the `debounce` dependency.
1 change: 0 additions & 1 deletion packages/react-email/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
"commander": "catalog:",
"conf": "^15.0.2",
"css-tree": "3.2.1",
"debounce": "^2.0.0",
"esbuild": "^0.28.0",
"glob": "^13.0.6",
"jiti": "2.6.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type http from 'node:http';
import path from 'node:path';
import { watch } from 'chokidar';
import debounce from 'debounce';
import { type Socket, Server as SocketServer } from 'socket.io';
import type { HotReloadChange } from '../../types/hot-reload-change.js';
import { createDependencyGraph } from './create-dependency-graph.js';
Expand All @@ -25,7 +24,14 @@ export const setupHotreloading = async (
// and send them at once to the preview app through the web socket
let changes = [] as HotReloadChange[];

const reload = debounce(() => {
// Waits for 150ms without new changes before sending them all at once
let reloadTimeout: NodeJS.Timeout | undefined;
const reload = () => {
clearTimeout(reloadTimeout);
reloadTimeout = setTimeout(sendChanges, 150);
};

const sendChanges = () => {
// we detect these using the useHotreload hook on the Next app
clients.forEach((client) => {
client.emit(
Expand All @@ -40,7 +46,7 @@ export const setupHotreloading = async (
});

changes = [];
}, 150);
};

const absolutePathToEmailsDirectory = path.resolve(
process.cwd(),
Expand Down
9 changes: 0 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.