Skip to content

Commit 0fb66fb

Browse files
committed
review fix
1 parent 3cf8784 commit 0fb66fb

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

packages/open-next/src/overrides/imageLoader/fs-dev.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
import fs from "node:fs/promises";
2-
import { Readable } from "node:stream";
1+
import fs from "node:fs";
32
import type { ImageLoader } from "types/overrides";
43

54
export default {
65
name: "fs-dev",
76
load: async (url: string) => {
87
const basePath = "../../assets";
9-
const fileData = await fs.readFile(`${basePath}/${url}`);
8+
const body = fs.createReadStream(`${basePath}/${url}`);
109
const contentType = url.endsWith(".png") ? "image/png" : "image/jpeg";
1110
return {
12-
body: Readable.from(fileData),
11+
body,
1312
contentType,
1413
cacheControl: "public, max-age=31536000, immutable",
1514
};

packages/open-next/src/overrides/incrementalCache/fs-dev.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ const cache: IncrementalCache = {
2323
},
2424
set: async (key, value, isFetch) => {
2525
const data = JSON.stringify(value);
26-
await fs.writeFile(getCacheKey(key), data);
26+
const cacheKey = getCacheKey(key);
27+
// We need to create the directory before writing the file
28+
await fs.mkdir(path.dirname(cacheKey), { recursive: true });
29+
await fs.writeFile(cacheKey, data);
2730
},
2831
delete: async (key) => {
2932
await fs.rm(getCacheKey(key));

packages/open-next/src/overrides/tagCache/fs-dev.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,13 @@ const tagCache: TagCache = {
3333
return revalidatedTags.length > 0 ? -1 : (lastModified ?? Date.now());
3434
},
3535
writeTags: async (newTags) => {
36-
const unchangedTags = tags.filter((tagPathMapping) =>
37-
newTags.some(
38-
(tag) =>
39-
tag.tag === tagPathMapping.tag.S &&
40-
tag.path === tagPathMapping.path.S,
41-
),
36+
const unchangedTags = tags.filter(
37+
(tagPathMapping) =>
38+
!newTags.some(
39+
(tag) =>
40+
tag.tag === tagPathMapping.tag.S &&
41+
tag.path === tagPathMapping.path.S,
42+
),
4243
);
4344
tags = unchangedTags.concat(
4445
newTags.map((tag) => ({

packages/open-next/src/overrides/wrappers/express-dev.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// dev/wrapper.ts
2-
// You'll need to install express
31
import express from "express";
42

53
import type { StreamCreator } from "types/open-next.js";
@@ -20,7 +18,6 @@ const wrapper: WrapperHandler = async (handler, converter) => {
2018
res.writeHead(prelude.statusCode, prelude.headers);
2119
return res;
2220
},
23-
onFinish: () => {},
2421
};
2522
await imageHandler(internalEvent, _res);
2623
});

0 commit comments

Comments
 (0)