Repository: parcel-bundler/parcel
File: packages/dev/query/src/cli.js (JavaScript)

Code before:
        }
      } else if (n.type == 'asset') {
        if (
          // $FlowFixMe
          fromProjectPathRelative(n.value.filePath).includes('node_modules')
        ) {
          bg.asset_node_modules++;
        } else {
          bg.asset_source++;
        }
      } else if (n.type == 'dependency') {
        bg.dependency++;
      } else if (n.type == 'entry_file') {
        bg_type.entries++;
      }
    }

    let sum = 0;
    for (let k in bg_ext) {
      sum += bg_ext[k];
    }

    invariant(bg.bundle == sum);

    _printStatsTable('# Asset Graph Node Counts', Object.entries(ag));
    _printStatsTable('# Bundle Graph Node Counts', Object.entries(bg));
    _printStatsTable('# Bundles By Type', Object.entries(bg_type));
    _printStatsTable('# Bundles By Extension', Object.entries(bg_ext));
  }

  // -------------------------------------------------------

  if (initialCmd != null) {
    eval(initialCmd);
    process.exit(0);
  } else {
    console.log(
      'See .help. The graphs can be accessed via `assetGraph`, `bundleGraph` and `requestTracker`.',
    );
    process.on('uncaughtException', function (err) {
      console.error(err);
      server.displayPrompt();
    });

    const server = repl.start({useColors: true, useGlobal: true});
    // $FlowFixMe[prop-missing]
    server.setupHistory(
      path.join(os.homedir(), '.parcel_query_history'),
      () => {},
    );


Review comment (suggestion):
I notice the BundleGraph table has `asset` count as well as `asset_nodemodules` and `asset_source` I think we can either remove the `asset` row for the bundleGraph table since we already have that count in the `AssetGraph` table, or, you can sum `asset_nodemodules + asset_source` to get the full count. Currently your example said 0 assets but the BundleGraph should contain all the asset nodes present in the AssetGraph

Code after:
      async: 0,
      parallel: 0,
      sync: 0,
    };

    let b_ext = {};

    const entries = new Set();

    for (let [, n] of bundleGraph._graph.nodes) {
      if (n.type === 'bundle_group') {
        bg.bundle_group++;
      } else if (n.type === 'bundle') {
        bg.bundle++;

        // $FlowFixMe
        b_ext[n.value.type] = (b_ext[n.value.type] || 0) + 1;

        // $FlowFixMe
        const entry_group = _findEntryBundle(bundleGraph, n);

        if (entry_group != null && !entries.has(entry_group.id)) {
          b_type.entry++;
          entries.add(entry_group.id);
        } else if (n.value.mainEntryId == null) {
          // In general, !bundle.mainEntryId means that it is shared. In the case of an async and shared bundle, only count it as shared.
          b_type.shared++;
        } else {
          const priority = _getBundlePriority(bundleGraph, n);

          if (priority == Priority.lazy) {
            b_type.async++;
          } else if (priority == Priority.parallel) {
            b_type.parallel++;
          } else if (priority == Priority.sync) {
            b_type.sync++;
          }
        }
      } else if (n.type === 'asset') {
        if (
          // $FlowFixMe
          fromProjectPathRelative(n.value.filePath).includes('node_modules')
        ) {
          bg.asset_node_modules++;
        } else {
          bg.asset_source++;
        }
      } else if (n.type === 'dependency') {
        bg.dependency++;
      }
    }