1- import { analyzePackageModuleType } from '../compute-type.js' ;
21import type {
32 ReportPluginResult ,
43 Message ,
@@ -24,29 +23,11 @@ export async function runDependencyAnalysis(
2423 const prodDependencies = Object . keys ( pkg . dependencies || { } ) . length ;
2524 const devDependencies = Object . keys ( pkg . devDependencies || { } ) . length ;
2625
27- let cjsDependencies = 0 ;
28- let esmDependencies = 0 ;
29-
3026 // Recursively traverse dependencies
31- async function traverse (
32- packagePath : string ,
33- depth : number ,
34- pathInTree : string
35- ) {
27+ async function traverse ( packagePath : string , pathInTree : string ) {
3628 const depPkg = await getPackageJson ( context . fs , packagePath ) ;
3729 if ( ! depPkg || ! depPkg . name ) return ;
3830
39- // Only count CJS/ESM for non-root packages
40- if ( depth > 0 ) {
41- const type = analyzePackageModuleType ( depPkg ) ;
42- if ( type === 'cjs' ) cjsDependencies ++ ;
43- if ( type === 'esm' ) esmDependencies ++ ;
44- if ( type === 'dual' ) {
45- cjsDependencies ++ ;
46- esmDependencies ++ ;
47- }
48- }
49-
5031 for ( const depName of Object . keys ( depPkg . dependencies || { } ) ) {
5132 let packageMatch = packageFiles . find ( ( packageFile ) =>
5233 normalizePath ( packageFile ) . endsWith (
@@ -65,23 +46,21 @@ export async function runDependencyAnalysis(
6546 }
6647
6748 if ( packageMatch ) {
68- await traverse ( packageMatch , depth + 1 , pathInTree + ' > ' + depName ) ;
49+ await traverse ( packageMatch , pathInTree + ' > ' + depName ) ;
6950 }
7051 }
7152 }
7253
7354 // Start traversal from root
74- await traverse ( '/package.json' , 0 , 'root' ) ;
55+ await traverse ( '/package.json' , 'root' ) ;
7556
7657 const stats : Partial < Stats > = {
7758 name : pkg . name ,
7859 version : pkg . version ,
7960 installSize,
8061 dependencyCount : {
8162 production : prodDependencies ,
82- development : devDependencies ,
83- esm : esmDependencies ,
84- cjs : cjsDependencies
63+ development : devDependencies
8564 }
8665 } ;
8766
0 commit comments