Skip to content

Commit e8e8ea7

Browse files
committed
feat: remove dev node_modules deps
1 parent affbe5d commit e8e8ea7

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

packages/open-next/src/build.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,25 @@ async function createServerBundle(monorepoRoot: string) {
489489
injectMiddlewareGeolocation(outputPath, packagePath);
490490
removeCachedPages(outputPath, packagePath);
491491
addCacheHandler(outputPath);
492+
493+
if (options.minify) {
494+
removeNodeModule(path.join(outputPath, "node_modules"), [
495+
"@esbuild",
496+
"prisma/libquery_engine-darwin-arm64.dylib.node",
497+
"@swc/core-darwin-arm64",
498+
"@swc/core",
499+
"better-sqlite3",
500+
"esbuild",
501+
"webpack",
502+
"uglify-js",
503+
// "react", // TODO: remove react/react-dom when nextjs updates its precompile versions
504+
// "react-dom",
505+
"@webassemblyjs",
506+
"uglify-js",
507+
"sass",
508+
"caniuse-lite",
509+
]);
510+
}
492511
}
493512

494513
function addMonorepoEntrypoint(outputPath: string, packagePath: string) {
@@ -743,3 +762,13 @@ function compareSemver(v1: string, v2: string): number {
743762
if (minor1 !== minor2) return minor1 - minor2;
744763
return patch1 - patch2;
745764
}
765+
766+
function removeNodeModule(nodeModulesPath: string, modules: string[]) {
767+
console.log("removing: ", modules);
768+
for (const module of modules) {
769+
fs.rmSync(path.join(nodeModulesPath, module), {
770+
force: true,
771+
recursive: true,
772+
});
773+
}
774+
}

0 commit comments

Comments
 (0)