Skip to content

Commit 7611f92

Browse files
caitpIgorMinar
authored andcommitted
fix(diffing-broccoli-plugin): wrapped trees are always stable
1 parent 7aa9751 commit 7611f92

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

tools/broccoli/broccoli.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ interface BroccoliTree {
5353
inputTree?: BroccoliTree;
5454
inputTrees?: BroccoliTree[];
5555

56+
/**
57+
* Trees which implement the rebuild api are wrapped automatically for api compat,
58+
* and `newStyleTree` keeps a reference to the original unwrapped tree.
59+
*/
60+
newStyleTree?: BroccoliTree;
61+
5662
/**
5763
* Description or name of the plugin used for reporting.
5864
*

tools/broccoli/diffing-broccoli-plugin.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ class DiffingPluginWrapper implements BroccoliTree {
6262
this.description = this.pluginClass.name;
6363
}
6464

65-
6665
private calculateDiff(firstRun: boolean): (DiffResult | DiffResult[]) {
6766
// TODO(caitp): optionally log trees based on environment variable or
6867
// command line option. It may be worth logging for trees where elapsed
@@ -146,6 +145,11 @@ class DiffingPluginWrapper implements BroccoliTree {
146145
// Ignore all DiffingPlugins as they are already stable, for others we don't know for sure
147146
// so we need to stabilize them.
148147
// Since it's not safe to use instanceof operator in node, we are checking the constructor.name.
149-
return (tree.constructor['name'] === 'DiffingPluginWrapper') ? tree : stabilizeTree(tree);
148+
//
149+
// New-styler/rebuild trees should always be stable.
150+
let isNewStyleTree = !!(tree['newStyleTree'] || typeof tree.rebuild === 'function' ||
151+
tree['isReadAPICompatTree'] || tree.constructor['name'] === 'Funnel');
152+
153+
return isNewStyleTree ? tree : stabilizeTree(tree);
150154
}
151155
}

0 commit comments

Comments
 (0)