Skip to content

Instantly share code, notes, and snippets.

@cibernox
Created August 24, 2017 22:18
Show Gist options
  • Save cibernox/ecb11e17ce49b9a7963d8b040b42615e to your computer and use it in GitHub Desktop.
Save cibernox/ecb11e17ce49b9a7963d8b040b42615e to your computer and use it in GitHub Desktop.
Plan to allow to analyze and postprocess trees crossing types boundaries

Problem

Addon developers want to make optimizations in which the analysis of one tree (p.e, templates or js trees, or both) enables optimizations on other trees (p.e. styles or public).] Right now ember-cli exposes preprocessTree(type, tree) and postprocessTree(type, tree), but they don't work for this purpose because

  1. The preprocessTree receives the individual tree types (app, styles, templates, test-support, public...), but there is no single three that gives the developers access to all those types simultaneously to perform cross-type operations.

  2. The postprocessTree does receive a tree named all that gives access to the final result of the build, but by then the processing has finished (sass have been compiled to css already, images have been concatenated into sprites, etc...), so it's too late for the user to do some transforms.

Proposed solution

Pass a tree named all to the preprocessTree hook like the postprocess tree already does, so users have access to the raw files before it's too late.

It is important that this tree is generated including the trees coming from addons, as the operation the developer wants to perform might also care about those.

@urbany
Copy link

urbany commented Aug 25, 2017

In an addon I'm developing I also needed access to the all tree in the preprocessTree hook, so I'm using this: this.app.trees.app to access it, but it might be the wrong way of doing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment