Skip to content

Commit

Permalink
fix(lockfile-file): check importers key for shared lockfile format
Browse files Browse the repository at this point in the history
The `convertFromLockfileFileMutable` function reverts changes from
`normalizeLockfile` when not using the shared lockfile format.

  - The non-shared lockfile format puts fields like `specifiers`,
    `dependencies`, `devDependencies`, `optionalDependencies`, and
    `dependenciesMeta` on the root of the lockfile. This is typically
    the case for a repo not using pnpm workspaces.
  - The shared lockfile format puts these under a `importers` block
    scoped by a path.

The `use-inline-specifiers-lockfile-format` feature flag removes the
`specifiers` block in favor of putting each specifier next to the
resolved version within each `dependencies`, `devDependencies`, etc
block.

This means the `convertFromLockfileFileMutable` function can no longer
check for `specifiers` to detect the whether the "shared" format is
used. @zkochan suggested checking for `importers` instead, which should
have the same effect.
pnpm#5091 (comment)
  • Loading branch information
gluxon committed Jul 26, 2022
1 parent baf8c0d commit d00ac32
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/lockfile-file/src/read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,10 @@ async function _readGitBranchLockfiles (
* Reverts changes from the "forceSharedFormat" write option if necessary.
*/
function convertFromLockfileFileMutable (lockfileFile: LockfileFile): Lockfile {
if (typeof lockfileFile?.['specifiers'] !== 'undefined') {
if (typeof lockfileFile?.['importers'] === 'undefined') {
lockfileFile.importers = {
'.': {
specifiers: lockfileFile['specifiers'],
specifiers: lockfileFile['specifiers'] ?? {},
dependenciesMeta: lockfileFile['dependenciesMeta'],
},
}
Expand Down

0 comments on commit d00ac32

Please sign in to comment.