Skip to content

Commit

Permalink
Add console.log inspect to Bundle/BundleGroup
Browse files Browse the repository at this point in the history
This allows them to be logged to console.log when debugging.

Test Plan: N/A

Pull Request: #334
  • Loading branch information
yamadapc committed Feb 6, 2025
1 parent 6950e34 commit dcb90d4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/core/core/src/public/Bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import Target from './Target';
import {BundleBehaviorNames} from '../types';
import {fromProjectPath} from '../projectPath';

const inspect = Symbol.for('nodejs.util.inspect.custom');

const internalBundleToBundle: DefaultWeakMap<
AtlaspackOptions,
DefaultWeakMap<BundleGraph, WeakMap<InternalBundle, Bundle>>,
Expand Down Expand Up @@ -69,6 +71,11 @@ export class Bundle implements IBundle {
#bundleGraph /*: BundleGraph */;
#options /*: AtlaspackOptions */;

// $FlowFixMe
[inspect]() {
return `Bundle(${this.#bundle.id})`;
}

constructor(
sentinel: mixed,
bundle: InternalBundle,
Expand Down
7 changes: 7 additions & 0 deletions packages/core/core/src/public/BundleGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export function bundleGroupToInternalBundleGroup(
return nullthrows(_bundleGroupToInternalBundleGroup.get(target));
}

const inspect = Symbol.for('nodejs.util.inspect.custom');

export default class BundleGroup implements IBundleGroup {
#bundleGroup /*: InternalBundleGroup */;
#options /*: AtlaspackOptions */;
Expand Down Expand Up @@ -52,4 +54,9 @@ export default class BundleGroup implements IBundleGroup {
get entryAssetId(): string {
return this.#bundleGroup.entryAssetId;
}

// $FlowFixMe
[inspect]() {
return `BundleGroup(${this.entryAssetId})`;
}
}

0 comments on commit dcb90d4

Please sign in to comment.