mirror of
https://github.com/pnpm/pnpm.git
synced 2026-04-10 18:18:56 -04:00
5
.changeset/lovely-kiwis-care.md
Normal file
5
.changeset/lovely-kiwis-care.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"supi": patch
|
||||
---
|
||||
|
||||
When a package is both a dev dependency and a prod dependency, the package should be linked when installing prod dependencies only. This was an issue only when a lockfile was not present during installation.
|
||||
@@ -83,7 +83,7 @@ export default async function linkPackages (
|
||||
depNodes = depNodes.filter(({ dev, optional }) => dev || optional)
|
||||
}
|
||||
if (!opts.include.devDependencies) {
|
||||
depNodes = depNodes.filter(({ dev }) => !dev)
|
||||
depNodes = depNodes.filter(({ optional, prod }) => prod || optional)
|
||||
}
|
||||
if (!opts.include.optionalDependencies) {
|
||||
depNodes = depNodes.filter(({ optional }) => !optional)
|
||||
@@ -150,12 +150,17 @@ export default async function linkPackages (
|
||||
.map(([rootAlias, depPath]) => ({ rootAlias, depGraphNode: depGraph[depPath] }))
|
||||
.filter(({ depGraphNode }) => depGraphNode)
|
||||
.map(async ({ rootAlias, depGraphNode }) => {
|
||||
const isDev = Boolean(manifest.devDependencies?.[depGraphNode.name])
|
||||
const isOptional = Boolean(manifest.optionalDependencies?.[depGraphNode.name])
|
||||
if (
|
||||
isDev && !opts.include.devDependencies ||
|
||||
isOptional && !opts.include.optionalDependencies ||
|
||||
!isDev && !isOptional && !opts.include.dependencies
|
||||
) return
|
||||
if (
|
||||
(await symlinkDependency(depGraphNode.dir, modulesDir, rootAlias)).reused
|
||||
) return
|
||||
|
||||
const isDev = Boolean(manifest.devDependencies?.[depGraphNode.name])
|
||||
const isOptional = Boolean(manifest.optionalDependencies?.[depGraphNode.name])
|
||||
rootLogger.debug({
|
||||
added: {
|
||||
dependencyType: isDev && 'dev' || isOptional && 'optional' || 'prod',
|
||||
|
||||
@@ -4,6 +4,7 @@ import { addDependenciesToPackage, install } from 'supi'
|
||||
import promisifyTape from 'tape-promise'
|
||||
import { testDefaults } from '../utils'
|
||||
import path = require('path')
|
||||
import exists = require('path-exists')
|
||||
import tape = require('tape')
|
||||
|
||||
const test = promisifyTape(tape)
|
||||
@@ -14,12 +15,17 @@ test('production install (with --production flag)', async (t: tape.Test) => {
|
||||
await install({
|
||||
dependencies: {
|
||||
'pkg-with-1-dep': '100.0.0',
|
||||
'write-yaml': '1.0.0',
|
||||
},
|
||||
devDependencies: {
|
||||
'@zkochan/foo': '1.0.0',
|
||||
once: '^1.4.0', // once is also a transitive dependency of rimraf
|
||||
// js-yaml is also a dependency of write-yaml
|
||||
// covers issue https://github.com/pnpm/pnpm/issues/2882
|
||||
'js-yaml': '3.14.0',
|
||||
once: '^1.4.0',
|
||||
},
|
||||
}, await testDefaults({
|
||||
fastUnpack: false,
|
||||
include: {
|
||||
dependencies: true,
|
||||
devDependencies: false,
|
||||
@@ -27,8 +33,44 @@ test('production install (with --production flag)', async (t: tape.Test) => {
|
||||
},
|
||||
}))
|
||||
|
||||
t.notOk(await exists(path.resolve('node_modules/.pnpm/@zkochan/foo@1.0.0')))
|
||||
t.ok(await exists(path.resolve('node_modules/.pnpm/js-yaml@3.14.0')))
|
||||
await project.has('pkg-with-1-dep')
|
||||
await project.has('write-yaml')
|
||||
await project.hasNot('@zkochan/foo')
|
||||
await project.hasNot('js-yaml')
|
||||
})
|
||||
|
||||
test('production install with --no-optional', async (t: tape.Test) => {
|
||||
const project = prepareEmpty(t)
|
||||
|
||||
await install({
|
||||
dependencies: {
|
||||
'pkg-with-1-dep': '100.0.0',
|
||||
'write-yaml': '1.0.0',
|
||||
},
|
||||
optionalDependencies: {
|
||||
'@zkochan/foo': '1.0.0',
|
||||
// js-yaml is also a dependency of write-yaml
|
||||
// covers issue https://github.com/pnpm/pnpm/issues/2882
|
||||
'js-yaml': '3.14.0',
|
||||
once: '^1.4.0',
|
||||
},
|
||||
}, await testDefaults({
|
||||
fastUnpack: false,
|
||||
include: {
|
||||
dependencies: true,
|
||||
devDependencies: false,
|
||||
optionalDependencies: false,
|
||||
},
|
||||
}))
|
||||
|
||||
t.notOk(await exists(path.resolve('node_modules/.pnpm/@zkochan/foo@1.0.0')))
|
||||
t.ok(await exists(path.resolve('node_modules/.pnpm/js-yaml@3.14.0')))
|
||||
await project.has('pkg-with-1-dep')
|
||||
await project.has('write-yaml')
|
||||
await project.hasNot('@zkochan/foo')
|
||||
await project.hasNot('js-yaml')
|
||||
})
|
||||
|
||||
test('install dev dependencies only', async (t: tape.Test) => {
|
||||
|
||||
Reference in New Issue
Block a user