Skip to content

Commit

Permalink
fix(arborist): save bundleDependencies to package.json when reifying
Browse files Browse the repository at this point in the history
  • Loading branch information
wraithgar committed Feb 8, 2022
1 parent fb6e2dd commit e631faf
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions workspaces/arborist/lib/arborist/reify.js
Original file line number Diff line number Diff line change
Expand Up @@ -1369,13 +1369,18 @@ module.exports = cls => class Reifier extends cls {
devDependencies = {},
optionalDependencies = {},
peerDependencies = {},
// bundleDependencies is not required by PackageJson like the other fields here
// PackageJson also doesn't omit an empty array for this field so defaulting this
// to an empty array would add that field to every package.json file.
bundleDependencies,
} = tree.package

pkgJson.update({
dependencies,
devDependencies,
optionalDependencies,
peerDependencies,
bundleDependencies,
})
await pkgJson.save()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33164,6 +33164,10 @@ exports[`test/arborist/reify.js TAP save-prod, with optional > must match snapsh
{"dependencies":{"abbrev":"^1.1.1"}}
`

exports[`test/arborist/reify.js TAP saveBundle > must match snapshot 1`] = `
{"dependencies":{"abbrev":"^1.1.1"},"bundleDependencies":["abbrev"]}
`

exports[`test/arborist/reify.js TAP saving the ideal tree save some stuff > lock after save 1`] = `
Object {
"dependencies": Object {
Expand Down
11 changes: 11 additions & 0 deletions workspaces/arborist/test/arborist/reify.js
Original file line number Diff line number Diff line change
Expand Up @@ -1783,6 +1783,17 @@ t.test('save-prod, with optional', async t => {
t.matchSnapshot(fs.readFileSync(path + '/package.json', 'utf8'))
})

t.test('saveBundle', async t => {
const path = t.testdir({
'package.json': JSON.stringify({
dependencies: { abbrev: '*' },
}),
})
const arb = newArb({ path })
await arb.reify({ add: ['abbrev'], saveType: 'prod', saveBundle: true })
t.matchSnapshot(fs.readFileSync(path + '/package.json', 'utf8'))
})

t.test('no saveType: dev w/ compatible peer', async t => {
const path = t.testdir({
'package.json': JSON.stringify({
Expand Down

0 comments on commit e631faf

Please sign in to comment.