From 82f469b3384dccc7dd7c602d4d2b496ec3b8c1b0 Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig <4586894+mischnic@users.noreply.github.com> Date: Thu, 11 Aug 2022 17:19:34 +0200 Subject: [PATCH] Edge types for asset graph --- packages/core/core/src/AssetGraph.js | 15 +++++++++++++-- packages/core/core/src/dumpGraphToGraphViz.js | 10 ++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/packages/core/core/src/AssetGraph.js b/packages/core/core/src/AssetGraph.js index 732e8c1368c..a4a913fee15 100644 --- a/packages/core/core/src/AssetGraph.js +++ b/packages/core/core/src/AssetGraph.js @@ -30,6 +30,14 @@ import {ContentGraph} from '@parcel/graph'; import {createDependency} from './Dependency'; import {type ProjectPath, fromProjectPathRelative} from './projectPath'; +export const assetGraphEdgeTypes = { + null: 1, + //TODO + original: 2, +}; + +export type AssetGraphEdgeType = $Values; + type InitOpts = {| entries?: Array, targets?: Array, @@ -43,7 +51,7 @@ type AssetGraphOpts = {| |}; type SerializedAssetGraph = {| - ...SerializedContentGraph, + ...SerializedContentGraph, hash?: ?string, symbolPropagationRan: boolean, |}; @@ -110,7 +118,10 @@ export function nodeFromEntryFile(entry: Entry): EntryFileNode { }; } -export default class AssetGraph extends ContentGraph { +export default class AssetGraph extends ContentGraph< + AssetGraphNode, + AssetGraphEdgeType, +> { onNodeRemoved: ?(nodeId: NodeId) => mixed; hash: ?string; envCache: Map; diff --git a/packages/core/core/src/dumpGraphToGraphViz.js b/packages/core/core/src/dumpGraphToGraphViz.js index ea60a519450..c3f383c3977 100644 --- a/packages/core/core/src/dumpGraphToGraphViz.js +++ b/packages/core/core/src/dumpGraphToGraphViz.js @@ -3,6 +3,8 @@ import type {Asset, BundleBehavior} from '@parcel/types'; import type {Graph} from '@parcel/graph'; import type {AssetGraphNode, BundleGraphNode, Environment} from './types'; +import type {AssetGraphEdgeType} from './AssetGraph'; +import {assetGraphEdgeTypes} from './AssetGraph'; import {bundleGraphEdgeTypes} from './BundleGraph'; import {requestGraphEdgeTypes} from './RequestTracker'; @@ -26,6 +28,7 @@ const TYPE_COLORS = { internal_async: 'orange', references: 'red', sibling: 'green', + original: 'grey', invalidated_by_create: 'green', invalidated_by_create_above: 'orange', invalidate_by_update: 'cyan', @@ -34,7 +37,7 @@ const TYPE_COLORS = { export default async function dumpGraphToGraphViz( graph: - | Graph + | Graph | Graph<{| assets: Array, sourceBundles: Array, @@ -42,7 +45,10 @@ export default async function dumpGraphToGraphViz( |}> | Graph, name: string, - edgeTypes?: typeof bundleGraphEdgeTypes | typeof requestGraphEdgeTypes, + edgeTypes?: + | typeof assetGraphEdgeTypes + | typeof bundleGraphEdgeTypes + | typeof requestGraphEdgeTypes, ): Promise { if ( process.env.PARCEL_BUILD_ENV === 'production' ||