@@ -6,13 +6,47 @@ const gitCommitHash = execSync('git rev-parse --short HEAD').toString().trim()
6
6
const releaseDate = new Date ( ) . toISOString ( ) . split ( 'T' ) [ 0 ]
7
7
8
8
const nextConfig : NextConfig = {
9
- // NOTE: Exclude '@prisma/internals' from the client-side bundle
10
- // This module is server-side only and should not be included in the client build
9
+ // NOTE: Exclude Prisma-related packages from the bundle
10
+ // These packages are installed separately in the node_modules/@prisma directory
11
+ // Excluding them prevents `Error: Cannot find module 'fs'` errors in the build process
11
12
webpack : ( config ) => {
12
- config . resolve . alias = {
13
- ...config . resolve . alias ,
14
- '@prisma/internals' : false ,
13
+ if ( Array . isArray ( config . externals ) ) {
14
+ config . externals . push (
15
+ '@prisma/debug' ,
16
+ '@prisma/engines' ,
17
+ '@prisma/engines-version' ,
18
+ '@prisma/fetch-engine' ,
19
+ '@prisma/generator-helper' ,
20
+ '@prisma/get-platform' ,
21
+ '@prisma/internals' ,
22
+ '@prisma/prisma-schema-wasm' ,
23
+ '@prisma/schema-files-loader' ,
24
+ )
25
+ } else {
26
+ config . externals [ '@prisma/debug' ] = '@prisma/debug'
27
+ config . externals [ '@prisma/engines' ] = '@prisma/engines'
28
+ config . externals [ '@prisma/engines-version' ] = '@prisma/engines-version'
29
+ config . externals [ '@prisma/fetch-engine' ] = '@prisma/fetch-engine'
30
+ config . externals [ '@prisma/generator-helper' ] = '@prisma/generator-helper'
31
+ config . externals [ '@prisma/get-platform' ] = '@prisma/get-platform'
32
+ config . externals [ '@prisma/internals' ] = '@prisma/internals'
33
+ config . externals [ '@prisma/prisma-schema-wasm' ] =
34
+ '@prisma/prisma-schema-wasm'
35
+ config . externals [ '@prisma/schema-files-loader' ] =
36
+ '@prisma/schema-files-loader'
15
37
}
38
+ config . plugins . push ( {
39
+ // biome-ignore lint/suspicious/noExplicitAny: webpack types are incomplete so we need to use any here
40
+ apply : ( compiler : any ) => {
41
+ compiler . hooks . afterEmit . tap ( 'InstallPrismaInternals' , ( ) => {
42
+ execSync ( 'node scripts/install-prisma-internals.mjs' , {
43
+ stdio : 'inherit' ,
44
+ cwd : __dirname ,
45
+ } )
46
+ } )
47
+ } ,
48
+ } )
49
+
16
50
return config
17
51
} ,
18
52
outputFileTracingIncludes : {
0 commit comments