@@ -4,6 +4,7 @@ import { createRequire as topLevelCreateRequire } from "node:module";
4
4
import path from "node:path" ;
5
5
import url from "node:url" ;
6
6
7
+ import { exec } from "child_process" ;
7
8
import {
8
9
build as buildAsync ,
9
10
BuildOptions as ESBuildOptions ,
@@ -709,7 +710,7 @@ async function createServerBundle(monorepoRoot: string, streaming = false) {
709
710
addCacheHandler ( outputPath , options . dangerous ) ;
710
711
711
712
removeNodeModule ( path . join ( outputPath , "node_modules" ) , [
712
- "@esbuild" ,
713
+ "@esbuild* " ,
713
714
"@prisma/engines/download" ,
714
715
"@prisma/internals/dist/libquery_engine*" ,
715
716
"@prisma/internals/dist/get-generators/libquery_engine*" ,
@@ -1026,11 +1027,23 @@ function compareSemver(v1: string, v2: string): number {
1026
1027
}
1027
1028
1028
1029
function removeNodeModule ( nodeModulesPath : string , modules : string [ ] ) {
1029
- console . log ( "removing: " , modules ) ;
1030
+ console . log ( "Removing: " , modules ) ;
1031
+ const isWindows = process . platform === "win32" ;
1032
+
1030
1033
for ( const module of modules ) {
1031
- fs . rmSync ( path . join ( nodeModulesPath , module ) , {
1032
- force : true ,
1033
- recursive : true ,
1034
- } ) ;
1034
+ const modulePath = path . join ( nodeModulesPath , module ) ;
1035
+ const pnpmModulePath = path . join ( nodeModulesPath , ".pnpm" , module ) ;
1036
+
1037
+ if ( isWindows ) {
1038
+ exec (
1039
+ `PowerShell -Command "Remove-Item -Path '${ modulePath } ' -Recurse -Force"` ,
1040
+ ) ;
1041
+ exec (
1042
+ `PowerShell -Command "Remove-Item -Path '${ pnpmModulePath } ' -Recurse -Force"` ,
1043
+ ) ;
1044
+ } else {
1045
+ exec ( `rm -rf ${ modulePath } ` ) ;
1046
+ exec ( `rm -rf ${ pnpmModulePath } ` ) ;
1047
+ }
1035
1048
}
1036
1049
}
0 commit comments