mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-21 16:27:18 +02:00
fix(dev): reduce static ui log and cache churn
This commit is contained in:
1 parent
11b0e69356
commit
7ed50a74d3
4 files changed
+12
-2
No files matched your search
@@ -53,6 +53,8 @@ describe("shouldSilenceHttpSuccessLog", () => {
|
||||
});
|
||||
|
||||
it("silences successful static asset requests", () => {
|
||||
expect(shouldSilenceHttpSuccessLog("GET", "/", 200)).toBe(true);
|
||||
expect(shouldSilenceHttpSuccessLog("GET", "/index.html", 200)).toBe(true);
|
||||
expect(shouldSilenceHttpSuccessLog("GET", "/@fs/Users/dotta/paperclip/ui/src/main.tsx", 200)).toBe(true);
|
||||
expect(shouldSilenceHttpSuccessLog("GET", "/src/App.tsx?t=123", 200)).toBe(true);
|
||||
expect(shouldSilenceHttpSuccessLog("GET", "/site.webmanifest", 200)).toBe(true);
|
||||
|
||||
@@ -32,7 +32,7 @@ describe("createCachedViteHtmlRenderer", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("reuses the injected dev html shell until a watched file changes", async () => {
|
||||
it("reuses the injected dev html shell until index.html changes", async () => {
|
||||
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "paperclip-vite-html-"));
|
||||
tempDirs.push(tempDir);
|
||||
const indexPath = path.join(tempDir, "index.html");
|
||||
@@ -57,6 +57,12 @@ describe("createCachedViteHtmlRenderer", () => {
|
||||
expect(first.match(/\/@vite\/client/g)?.length).toBe(1);
|
||||
expect(first).toContain("window.$RefreshReg$");
|
||||
|
||||
const sourcePath = path.join(tempDir, "src", "main.tsx");
|
||||
fs.mkdirSync(path.dirname(sourcePath), { recursive: true });
|
||||
fs.writeFileSync(sourcePath, "export {};\n", "utf8");
|
||||
watcher.emit("change", sourcePath);
|
||||
expect(await renderer.render("/")).toBe(first);
|
||||
|
||||
fs.writeFileSync(
|
||||
indexPath,
|
||||
'<html><body>v2<script type="module" src="/src/main.tsx"></script></body></html>',
|
||||
|
||||
@@ -23,6 +23,8 @@ const SILENCED_SUCCESS_STATIC_PREFIXES = [
|
||||
];
|
||||
|
||||
const SILENCED_SUCCESS_STATIC_PATHS = new Set([
|
||||
"/",
|
||||
"/index.html",
|
||||
"/favicon.ico",
|
||||
"/site.webmanifest",
|
||||
"/sw.js",
|
||||
|
||||
@@ -63,7 +63,7 @@ export function createCachedViteHtmlRenderer(opts: {
|
||||
|
||||
function onWatchEvent(filePath: string): void {
|
||||
const resolvedPath = path.resolve(filePath);
|
||||
if (resolvedPath === templatePath || resolvedPath.startsWith(`${uiRoot}${path.sep}`)) {
|
||||
if (resolvedPath === templatePath) {
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user