@@ -21,7 +21,6 @@ import { naturalCompare } from '@socketsecurity/registry/lib/sorts'
2121
2222import baseConfig from './rollup.base.config.mjs'
2323import constants from '../scripts/constants.js'
24- import { formatObject } from '../scripts/utils/objects.js'
2524import {
2625 getPackageName ,
2726 isBuiltin ,
@@ -165,6 +164,8 @@ async function updateDepStats(depStats) {
165164 )
166165 )
167166 )
167+ // Remove Sentry as a direct dependency by default.
168+ delete depStats . dependencies [ SENTRY_NODE ]
168169 // Remove transitives from dependencies.
169170 for ( const key of Object . keys ( oldDepStats ?. transitives ?? { } ) ) {
170171 if ( pkgJson . dependencies [ key ] ) {
@@ -173,20 +174,18 @@ async function updateDepStats(depStats) {
173174 delete depStats . dependencies [ key ]
174175 }
175176 }
177+ // Lazily access constants.ENV[SOCKET_IS_SENTRY_BUILD].
178+ if ( constants . ENV [ SOCKET_IS_SENTRY_BUILD ] ) {
179+ // Add Sentry as a direct dependency for this build.
180+ depStats . dependencies [ SENTRY_NODE ] = ( await getSentryManifest ( ) ) . version
181+ }
176182 depStats . dependencies = toSortedObject ( depStats . dependencies )
177183 depStats . devDependencies = toSortedObject ( depStats . devDependencies )
178184 depStats . esm = toSortedObject ( depStats . esm )
179185 depStats . external = toSortedObject ( depStats . external )
180186 depStats . transitives = toSortedObject ( depStats . transitives )
181- // Lazily access constants.ENV[SOCKET_IS_SENTRY_BUILD].
182- if ( constants . ENV [ SOCKET_IS_SENTRY_BUILD ] ) {
183- // Add Sentry as a regular dep for this build.
184- depStats . dependencies [ SENTRY_NODE ] = ( await getSentryManifest ( ) ) . version
185- } else {
186- delete depStats . dependencies [ SENTRY_NODE ]
187- }
188187 // Write dep stats.
189- await fs . writeFile ( depStatsPath , ` ${ formatObject ( depStats ) } \n` , 'utf8' )
188+ await writeJson ( depStatsPath , toSortedObject ( depStats ) , { spaces : 2 } )
190189 // Update dependencies with additional inlined modules.
191190 editablePkgJson . update ( {
192191 dependencies : {
0 commit comments