Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

Never bundle when saving as peer/peerOptional #255

Merged
merged 1 commit into from
Mar 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/add-rm-pkg-deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const addSingle = ({pkg, spec, saveBundle, saveType}) => {
pkg.devDependencies[name] = pkg.peerDependencies[name]
}

if (saveBundle) {
if (saveBundle && saveType !== 'peer' && saveType !== 'peerOptional') {
// keep it sorted, keep it unique
const bd = new Set(pkg.bundleDependencies || [])
bd.add(spec.name)
Expand Down
30 changes: 30 additions & 0 deletions test/add-rm-pkg-deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,36 @@ t.test('add', t => {
bundleDependencies: ['bar', 'foo'],
}, 'move to bundle deps, foo to deps, leave bar version unchanged')

t.strictSame(add({
pkg: {
dependencies: { bar: '1' },
devDependencies: { foo: '2' },
},
add: [foo1, bar],
saveBundle: true,
saveType: 'peer',
}), {
devDependencies: { foo: '1' },
peerDependencies: { foo: '1', bar: '*' },
}, 'never bundle peerDeps')

t.strictSame(add({
pkg: {
dependencies: { bar: '1' },
devDependencies: { foo: '2' },
},
add: [foo1, bar],
saveBundle: true,
saveType: 'peerOptional',
}), {
devDependencies: { foo: '1' },
peerDependencies: { foo: '1', bar: '*' },
peerDependenciesMeta: {
foo: { optional: true },
bar: { optional: true },
},
}, 'never bundle peerDeps')

t.strictSame(add({
pkg: {},
add: [foo1, bar],
Expand Down