From 7611f92f5bb9f603b6bb7142282f9abe3bd3a8f0 Mon Sep 17 00:00:00 2001 From: Caitlin Potter Date: Sun, 7 Jun 2015 17:56:35 -0400 Subject: [PATCH] fix(diffing-broccoli-plugin): wrapped trees are always stable --- tools/broccoli/broccoli.d.ts | 6 ++++++ tools/broccoli/diffing-broccoli-plugin.ts | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tools/broccoli/broccoli.d.ts b/tools/broccoli/broccoli.d.ts index 3f5aac746b..d058488c82 100644 --- a/tools/broccoli/broccoli.d.ts +++ b/tools/broccoli/broccoli.d.ts @@ -53,6 +53,12 @@ interface BroccoliTree { inputTree?: BroccoliTree; inputTrees?: BroccoliTree[]; + /** + * Trees which implement the rebuild api are wrapped automatically for api compat, + * and `newStyleTree` keeps a reference to the original unwrapped tree. + */ + newStyleTree?: BroccoliTree; + /** * Description or name of the plugin used for reporting. * diff --git a/tools/broccoli/diffing-broccoli-plugin.ts b/tools/broccoli/diffing-broccoli-plugin.ts index 2006856a12..a7762df712 100644 --- a/tools/broccoli/diffing-broccoli-plugin.ts +++ b/tools/broccoli/diffing-broccoli-plugin.ts @@ -62,7 +62,6 @@ class DiffingPluginWrapper implements BroccoliTree { this.description = this.pluginClass.name; } - private calculateDiff(firstRun: boolean): (DiffResult | DiffResult[]) { // TODO(caitp): optionally log trees based on environment variable or // command line option. It may be worth logging for trees where elapsed @@ -146,6 +145,11 @@ class DiffingPluginWrapper implements BroccoliTree { // Ignore all DiffingPlugins as they are already stable, for others we don't know for sure // so we need to stabilize them. // Since it's not safe to use instanceof operator in node, we are checking the constructor.name. - return (tree.constructor['name'] === 'DiffingPluginWrapper') ? tree : stabilizeTree(tree); + // + // New-styler/rebuild trees should always be stable. + let isNewStyleTree = !!(tree['newStyleTree'] || typeof tree.rebuild === 'function' || + tree['isReadAPICompatTree'] || tree.constructor['name'] === 'Funnel'); + + return isNewStyleTree ? tree : stabilizeTree(tree); } }