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

Cache Project model config. #7270

Merged
merged 1 commit into from
Aug 2, 2017
Merged

Cache Project model config. #7270

merged 1 commit into from
Aug 2, 2017

Conversation

krisselden
Copy link
Contributor

Add-ons have the expectation that project.config is "cheap" to call and this is not true. The config for a build should be stable.

@@ -171,7 +171,7 @@ class Builder extends CoreObject {
.catch(error => {
this.processAddonBuildSteps('buildError', error);
throw error;
});
}).finally(() => this.project.configCache.clear());
Copy link
Member

Choose a reason for hiding this comment

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

Minor nit-pick, the rest of this promise chain is dot aligned, I would expect this .finally to be on the next line.

@@ -52,6 +52,7 @@ class Project {
this.setupNodeModulesPath();
this.addonDiscovery = new AddonDiscovery(this.ui);
this.addonsFactory = new AddonsFactory(this, this);
this.configCache = new Map();
Copy link
Member

Choose a reason for hiding this comment

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

Can you make this _configCache? We don't want it to be considered public API on Project.

* @param {String} env Environment name
* @return {Object} Merged confiration object
*/
configWithoutCache(env) {
Copy link
Member

Choose a reason for hiding this comment

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

Can you underscore this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I doc'd it as private is that not enough?

Copy link
Contributor Author

@krisselden krisselden Jul 28, 2017

Choose a reason for hiding this comment

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

there is a lot of @private methods without underscore.

@rwjblue
Copy link
Member

rwjblue commented Jul 29, 2017

@krisselden and I tracked down the failure to an issue with an addon mutating the provided EmberENV

Addons have the expectation that project.config is
"cheap" to call, and this is not true.  The config
for a build should be stable.
@rwjblue rwjblue changed the base branch from master to beta July 31, 2017 13:35
@rwjblue
Copy link
Member

rwjblue commented Jul 31, 2017

Updates:

  • I fixed the mutation issue in the PR's that cross-linked here (mostly from ember-cli-htmlbars / ember-cli-htmlbars-inline-precompile). Once those were fixed and released, the previously hanging tests pass.
  • I updated the target branch of this to be beta, and rebased. This will go out in 2.15.

@rwjblue
Copy link
Member

rwjblue commented Jul 31, 2017

Ugh, CI is now failing due to a bad merge conflict resolution I did when merging release into beta branch. I'll need to fix that before we can land this (cross linking #7276).

@rwjblue
Copy link
Member

rwjblue commented Aug 2, 2017

#7276 was fixed, restarting Travis now...

@rwjblue rwjblue merged commit 24e1a61 into beta Aug 2, 2017
@rwjblue rwjblue deleted the project-config-cache branch August 2, 2017 17:27
@vitch
Copy link

vitch commented Dec 12, 2017

This change has had an undesired effect on our code which I just noticed while trying to update ember-cli from 2.12 to 2.16...

We may have been abusing the config hook previously so here is a bit more about our use-case:

We want to change the contents of our addon's merged config dependent on a setting from the consuming app. We were achieving this by setting a variable in the addons included hook and accessing it from the config hook.

The first time config fired was before included had fired. But it fired (many) more times and some of those were after the included hook had fired. Which meant that the config as rendered to the apps meta tag was correct.

Should a workflow like this be supported? Is there any way for the config hook to access a variable from the consuming app (we were using an option in ember-cli-build but we could change this) when it first fires?

The reason that we want to do this at compile-time rather than run-time is to redact certain pieces of config on publicly visible apps, otherwise we could just filter at runtime when all of the variables are available...

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.

3 participants