Skip to content

Commit

Permalink
fix(deps-optimization): detect yarn dependency changes correctly (vit…
Browse files Browse the repository at this point in the history
  • Loading branch information
DreierF committed Nov 5, 2024
1 parent 5f10e62 commit 801f910
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions packages/vite/src/node/optimizer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1145,28 +1145,45 @@ function isSingleDefaultExport(exports: readonly string[]) {
}

const lockfileFormats = [
// Prefer over package-lock.json as it will only be updated after `npm install` ran
{
name: '.package-lock.json',
path: 'node_modules/.package-lock.json',
checkPatches: true,
manager: 'npm',
},
{ name: 'package-lock.json', checkPatches: true, manager: 'npm' },
{ name: 'yarn.lock', checkPatches: true, manager: 'yarn' }, // Included in lockfile for v2+
// Prefer over pnpm-lock.yaml as it will only be updated after `pnpm install` ran
{
// Yarn non-PnP
name: '.yarn-state.yml',
path: 'node_modules/.yarn-state.yml',
checkPatches: false,
manager: 'yarn',
},
{
// Yarn PnP
name: 'install-state',
path: '.yarn/install-state',
checkPatches: false,
manager: 'yarn',
},
{
// yarn 1
name: '.yarn-integrity',
path: 'node_modules/.yarn-integrity',
checkPatches: true,
manager: 'yarn',
},
{
name: 'lock.yaml',
path: 'node_modules/.pnpm/lock.yaml',
// Included in lockfile
checkPatches: false,
manager: 'pnpm',
}, // Included in lockfile
{ name: 'pnpm-lock.yaml', checkPatches: false, manager: 'pnpm' }, // Included in lockfile
{ name: 'bun.lockb', checkPatches: true, manager: 'bun' },
},
{ name: 'bun.lockb', path: 'bun.lockb', checkPatches: true, manager: 'bun' },
].sort((_, { manager }) => {
return process.env.npm_config_user_agent?.startsWith(manager) ? 1 : -1
})
const lockfilePaths = lockfileFormats.map((l) => l.path ?? l.name)
const lockfilePaths = lockfileFormats.map((l) => l.path)

function getConfigHash(environment: Environment): string {
// Take config into account
Expand Down

0 comments on commit 801f910

Please sign in to comment.