Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding support for addons that use treeFor() to suppress various trees #566

Merged
merged 2 commits into from
Oct 11, 2020

Conversation

ef4
Copy link
Contributor

@ef4 ef4 commented Oct 10, 2020

In general, we can't run custom treeFor() hooks because they expect to recurse into all their child addons and have visibility into the output of all their child addons, which we forbid.

But the most common use case for treeFor() is quite simple, and we can opportunistically handle that case. It's the case where treeFor is returning either falsy or the unchanged output of _super.treeFor().

This lets us detect those cases and suppress trees that are supposed to get suppressed.

In general, we can't run custom `treeFor()` hooks because they expect to recurse into all their child addons and have visibility into the output of all their child addons, which we forbid.

But the most common use case for `treeFor()` is quite simple, and we *can* opportunistically handle that case. It's the case where treeFor is returning either falsy or the unchanged output of `_super.treeFor()`.

This letse us detect those cases and suppress trees that are supposed to get suppressed.
@ef4 ef4 changed the title adding support to addons that use treeFor() to suppress various trees adding support for addons that use treeFor() to suppress various trees Oct 10, 2020
@ef4
Copy link
Contributor Author

ef4 commented Oct 10, 2020

(Needs tests and needs deletion of several built-in compat adapters that should no longer be needed after this change.)

@ef4 ef4 marked this pull request as ready for review October 11, 2020 02:25
@ef4 ef4 merged commit c4b20e5 into master Oct 11, 2020
@ef4 ef4 deleted the tree-suppression branch October 11, 2020 03:29
@@ -919,3 +956,10 @@ function babelPluginAllowedInStage1(plugin: PluginItem) {
function notColocatedTemplate(path: string) {
return !/^\.\/components\/.*\.hbs$/.test(path);
}

const markedEmptyTree = new UnwatchedDir(process.cwd());
const returnMarkedEmptyTree = {
Copy link
Collaborator

@thoov thoov Oct 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ef4 I ran into an issue with this on an addon that calls this._super instead of this._super.treeFor. Currently the way we are mocking this as a POJO results them getting an error with: Uncaught TypeError: this._super is not a function. Obviously, this can easily be fixed by changing their call to this._super.treeFor but not sure how wide spread calling this._super is or if that is even something we should support.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, yeah, we can support that. It looks like core-object supports both, which is... ugh.

I filed #569

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants