@@ -1150,14 +1150,40 @@ function isSingleDefaultExport(exports: readonly string[]) {
1150
1150
}
1151
1151
1152
1152
const lockfileFormats = [
1153
- { name : 'package-lock.json' , checkPatches : true , manager : 'npm' } ,
1154
- { name : 'yarn.lock' , checkPatches : true , manager : 'yarn' } , // Included in lockfile for v2+
1155
- { name : 'pnpm-lock.yaml' , checkPatches : false , manager : 'pnpm' } , // Included in lockfile
1156
- { name : 'bun.lockb' , checkPatches : true , manager : 'bun' } ,
1153
+ {
1154
+ path : 'node_modules/.package-lock.json' ,
1155
+ checkPatches : true ,
1156
+ manager : 'npm' ,
1157
+ } ,
1158
+ {
1159
+ // Yarn non-PnP
1160
+ path : 'node_modules/.yarn-state.yml' ,
1161
+ checkPatches : false ,
1162
+ manager : 'yarn' ,
1163
+ } ,
1164
+ {
1165
+ // Yarn PnP
1166
+ path : '.yarn/install-state' ,
1167
+ checkPatches : false ,
1168
+ manager : 'yarn' ,
1169
+ } ,
1170
+ {
1171
+ // yarn 1
1172
+ path : 'node_modules/.yarn-integrity' ,
1173
+ checkPatches : true ,
1174
+ manager : 'yarn' ,
1175
+ } ,
1176
+ {
1177
+ path : 'node_modules/.pnpm/lock.yaml' ,
1178
+ // Included in lockfile
1179
+ checkPatches : false ,
1180
+ manager : 'pnpm' ,
1181
+ } ,
1182
+ { name : 'bun.lockb' , path : 'bun.lockb' , checkPatches : true , manager : 'bun' } ,
1157
1183
] . sort ( ( _ , { manager } ) => {
1158
1184
return process . env . npm_config_user_agent ?. startsWith ( manager ) ? 1 : - 1
1159
1185
} )
1160
- const lockfileNames = lockfileFormats . map ( ( l ) => l . name )
1186
+ const lockfilePaths = lockfileFormats . map ( ( l ) => l . path )
1161
1187
1162
1188
function getConfigHash ( environment : Environment ) : string {
1163
1189
// Take config into account
@@ -1195,16 +1221,17 @@ function getConfigHash(environment: Environment): string {
1195
1221
}
1196
1222
1197
1223
function getLockfileHash ( environment : Environment ) : string {
1198
- const lockfilePath = lookupFile ( environment . config . root , lockfileNames )
1224
+ const lockfilePath = lookupFile ( environment . config . root , lockfilePaths )
1199
1225
let content = lockfilePath ? fs . readFileSync ( lockfilePath , 'utf-8' ) : ''
1200
1226
if ( lockfilePath ) {
1201
- const lockfileName = path . basename ( lockfilePath )
1202
- const { checkPatches } = lockfileFormats . find (
1203
- ( f ) => f . name === lockfileName ,
1227
+ const normalizedLockfilePath = lockfilePath . replaceAll ( '\\' , '/' )
1228
+ const lockfileFormat = lockfileFormats . find ( ( f ) =>
1229
+ normalizedLockfilePath . endsWith ( f . path ) ,
1204
1230
) !
1205
- if ( checkPatches ) {
1231
+ if ( lockfileFormat . checkPatches ) {
1206
1232
// Default of https://github.com/ds300/patch-package
1207
- const fullPath = path . join ( path . dirname ( lockfilePath ) , 'patches' )
1233
+ const baseDir = lockfilePath . slice ( 0 , - lockfileFormat . path . length )
1234
+ const fullPath = path . join ( baseDir , 'patches' )
1208
1235
const stat = tryStatSync ( fullPath )
1209
1236
if ( stat ?. isDirectory ( ) ) {
1210
1237
content += stat . mtimeMs . toString ( )
0 commit comments