Skip to content

Commit f9c7b0d

Browse files
committed
review
1 parent f230586 commit f9c7b0d

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

packages/open-next/src/build/copyTracedFiles.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,23 @@ import { MIDDLEWARE_TRACE_FILE } from "./constant.js";
1919

2020
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
2121

22+
//TODO: we need to figure which packages we could safely remove
23+
const EXCLUDED_PACKAGES = [
24+
"caniuse-lite",
25+
"sharp",
26+
// This seems to be only in Next 15
27+
// Some of sharp deps are under the @img scope
28+
"@img",
29+
];
30+
31+
function isExcluded(srcPath: string) {
32+
return EXCLUDED_PACKAGES.some((excluded) =>
33+
new RegExp(`${path.sep}node_modules${path.sep}${excluded}${path.sep}`).test(
34+
srcPath,
35+
),
36+
);
37+
}
38+
2239
function copyPatchFile(outputDir: string) {
2340
const patchFile = path.join(__dirname, "patch", "patchedAsyncStorage.js");
2441
const outputPatchFile = path.join(outputDir, "patchedAsyncStorage.cjs");
@@ -194,15 +211,8 @@ File ${fullFilePath} does not exist
194211

195212
//Actually copy the files
196213
filesToCopy.forEach((to, from) => {
197-
if (
198-
//TODO: we need to figure which packages we could safely remove
199-
from.includes(path.join("node_modules", "caniuse-lite")) ||
200-
// from.includes("jest-worker") || This ones seems necessary for next 12
201-
from.includes(path.join("node_modules", "sharp")) ||
202-
// This seems to be only in Next 15
203-
// Some of sharp deps are under the @img scope
204-
from.includes(path.join("node_modules", "@img"))
205-
) {
214+
// We don't want to copy excluded packages (i.e sharp)
215+
if (isExcluded(from)) {
206216
return;
207217
}
208218
mkdirSync(path.dirname(to), { recursive: true });

0 commit comments

Comments
 (0)