fix(deploy): omit inject workspace packages setting in deploy lockfiles (#10294)

* fix(deploy): omit inject workspace packages setting in deploy lockfiles

When the deploy command creates a new lockfile, create the deployment
lockfile without the setting to inject workspace packages, because it
has already been applied when creating the lockfile and the deployment
is not, itself, a workspace.

* docs: add changesets

---------

Co-authored-by: Zoltan Kochan <z@kochan.io>
This commit is contained in:
Randall Leeds
2025-12-12 05:33:37 -08:00
committed by GitHub
parent 144d76f15f
commit 8385a8cff6
4 changed files with 60 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/plugin-commands-deploy": patch
"pnpm": patch
---
Remove the `injectWorkspacePackages` setting from the lockfile on the `deploy` command [#10294](https://github.com/pnpm/pnpm/pull/10294).

View File

@@ -123,6 +123,10 @@ export function createDeployFiles ({
overrides: undefined, // the effects of the overrides should already be part of the package snapshots
packageExtensionsChecksum: undefined, // the effects of the package extensions should already be part of the package snapshots
pnpmfileChecksum: undefined, // the effects of the pnpmfile should already be part of the package snapshots
settings: {
...lockfile.settings,
injectWorkspacePackages: undefined, // the effects of injecting workspace packages should already be part of the lockfile
},
importers: {
['.' as ProjectId]: targetSnapshot,
},

View File

@@ -265,6 +265,7 @@ async function deployFromSharedLockfile (
modulesDir: undefined,
confirmModulesPurge: false,
frozenLockfile: true,
injectWorkspacePackages: undefined, // the effects of injecting workspace packages should already be part of the package snapshots
overrides: undefined, // the effects of the overrides should already be part of the package snapshots
hooks: {
...opts.hooks,

View File

@@ -5,6 +5,7 @@ import { preparePackages } from '@pnpm/prepare'
import { filterPackagesFromDir } from '@pnpm/workspace.filter-packages-from-dir'
import { jest } from '@jest/globals'
import { DEFAULT_OPTS } from './utils/index.js'
import { install } from '@pnpm/plugin-commands-installation'
const original = await import('@pnpm/logger')
const warn = jest.fn()
@@ -498,3 +499,51 @@ test('deploy works when workspace packages use catalog protocol', async () => {
// Make sure the is-positive cataloged dependency was actually installed.
expect(fs.existsSync('deploy/node_modules/.pnpm/project-3@file+project-3/node_modules/is-positive')).toBeTruthy()
})
test('deploy does not preserve the inject workspace packages settings in the lockfile', async () => {
preparePackages([
{
location: '.',
package: {
name: 'root',
version: '1.0.0',
private: true,
},
},
{
name: 'project',
version: '1.0.0',
},
])
const { allProjects, selectedProjectsGraph } = await filterPackagesFromDir(process.cwd(), [{ namePattern: 'project' }])
await install.handler({
...DEFAULT_OPTS,
allProjects,
dir: process.cwd(),
dev: true,
production: true,
lockfileOnly: true,
sharedWorkspaceLockfile: true,
lockfileDir: process.cwd(),
workspaceDir: process.cwd(),
})
await deploy.handler({
...DEFAULT_OPTS,
allProjects,
dir: process.cwd(),
dev: false,
production: true,
recursive: true,
selectedProjectsGraph,
sharedWorkspaceLockfile: true,
lockfileDir: process.cwd(),
workspaceDir: process.cwd(),
}, ['dist'])
const project = assertProject(path.resolve('dist'))
const lockfile = project.readLockfile()
expect(lockfile.settings).not.toHaveProperty('injectWorkspacePackages')
})