diff --git a/workspaces/arborist/lib/arborist/reify.js b/workspaces/arborist/lib/arborist/reify.js index 45ef93985358b..91507fd791871 100644 --- a/workspaces/arborist/lib/arborist/reify.js +++ b/workspaces/arborist/lib/arborist/reify.js @@ -1369,6 +1369,10 @@ 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({ @@ -1376,6 +1380,7 @@ module.exports = cls => class Reifier extends cls { devDependencies, optionalDependencies, peerDependencies, + bundleDependencies, }) await pkgJson.save() } diff --git a/workspaces/arborist/tap-snapshots/test/arborist/reify.js.test.cjs b/workspaces/arborist/tap-snapshots/test/arborist/reify.js.test.cjs index 6d38d724dca22..ffd568c686103 100644 --- a/workspaces/arborist/tap-snapshots/test/arborist/reify.js.test.cjs +++ b/workspaces/arborist/tap-snapshots/test/arborist/reify.js.test.cjs @@ -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 { diff --git a/workspaces/arborist/test/arborist/reify.js b/workspaces/arborist/test/arborist/reify.js index caa15f59f2476..7fb1f1f2bfdf8 100644 --- a/workspaces/arborist/test/arborist/reify.js +++ b/workspaces/arborist/test/arborist/reify.js @@ -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({