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

[BUGFIX release] MODEL_FACTORY_INJECTIONS is now always false. #15204

Merged
merged 1 commit into from
May 15, 2017

Conversation

stefanpenner
Copy link
Member

@stefanpenner stefanpenner commented May 3, 2017

Double extend means this flag no longer means what it once did. To ensure ember-data functions correctly, we should now force it to always be false.

Code affect in ember-data is: https://github.com/emberjs/data/blob/e6cb564bdb33da4b3c15c3c668dc4b1fdafdf190/addon/-debug/index.js#L37-L39


@stefanpenner
Copy link
Member Author

This (if others agree) should likely join w/e release/beta/canary that disables double extend so that ember-data works correctly even if the user has the flag set to true.

// default false
ENV.MODEL_FACTORY_INJECTIONS = defaultFalse(ENV.MODEL_FACTORY_INJECTIONS);
// always false
Object.defineProperty(ENV, 'MODEL_FACTORY_INJECTIONS', {
Copy link
Member

Choose a reason for hiding this comment

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

We should issue a deprecation if MODEL_FACTORY_INJECTIONS in ENV, and update ember-cli to confirm it isn't specified in the blueprint.

Then instead of setting it to false here, we just leave it undefined (which would also be seen as falsey by ED's assertion).

set(value) { ENV.MODEL_FACTORY_INJECTIONS = !!value; },
get() { return false; },
set(value) {
Ember.logger.warn('As of 2.13.x MODEL_FACTORY_INJECTIONS has no power, feel free to remove it from app/app.js');
Copy link
Member

Choose a reason for hiding this comment

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

Should be an assertion, and this whole Object.defineProperty block should be in an if (DEBUG) {.

Copy link
Member Author

Choose a reason for hiding this comment

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

Assertion sounds good but I don't think we can strip the flag as users who ignore the deprecation and set the flag to true will have a bad time.

Copy link
Member

Choose a reason for hiding this comment

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

@stefanpenner - Setting it to true has literally no effect in production builds. The only usage that I can see in Ember Data is here which is also in an if (DEBUG) and therefore stripped in production builds.

The only thing we need to make sure to do here, is blow up if someone attempts to Ember.ENV.MODEL_FACTORY_INJECTIONS = <anything> in debug builds, because in production builds there is no behavior changes anyways...

@rwjblue
Copy link
Member

rwjblue commented May 4, 2017

Also, I agree, we should backport to release branch for a 2.13.1 release.

@stefanpenner
Copy link
Member Author

and update ember-cli to confirm it isn't specified in the blueprint.

This is a tad tricky, as it may be confusing for users upgrading ember + ember-cli but not ember-data ? Thoughts?

@rwjblue
Copy link
Member

rwjblue commented May 4, 2017

The ember-cli blueprints assume the package versions specified in that blueprints package.json. If the user isn't updating ember-data, they can't remove the flag either.

The main things I'm concerned with (and my comments would address) are:

  • We have finally removed special meaning of this flag in Ember, we shouldn't bloat Embers file size permenantly just to set a flag to a falsey value (which is what it's value would be anyways 😜).
  • Keeping the flag around, when it has no effect is pretty confusing. A properly worded deprecation (with a link to the deprecations page for more details) can provide the right context to provide folks with guidance.

@stefanpenner
Copy link
Member Author

Keeping the flag around, when it has no effect is pretty confusing.

Ya, it has an affect that effect is backward compact to ease upgrading. Let keep it around for an LTS and then drop it? (like other deprecations)

Sounds ok?

@rwjblue
Copy link
Member

rwjblue commented May 4, 2017

Ya, it has an affect that effect is backward compact to ease upgrading. Let keep it around for an LTS and then drop it? (like other deprecations)

It actually has no effect in production versions (as I mentioned and linked to code for in another comment), I'm super happy to keep both the deprecation (when MODEL_FACTORY_INJECTIONS in ENV) in packages/ember-environment/lib/index.js and either a deprecation or assertion in packages/ember/lib/index.js until 2.16 but both should be in an if (DEBUG) { flag so it is stripped in production.

@rwjblue
Copy link
Member

rwjblue commented May 4, 2017

FWIW, I checked ember-data back to v2.2.0 and the only thing that it was using the MODEL_FACTORY_INJECTIONS flag for in addon/ dir was this same assertion.

@stefanpenner
Copy link
Member Author

It actually has no effect in production versions (

Ya good point. Ok we can strip that one out in prod builds!

@stefanpenner stefanpenner force-pushed the model-factory-injections branch 2 times, most recently from 59ad983 to 5568817 Compare May 4, 2017 19:33
false,
{
id: 'ember-metal.model_factory_injections',
until: '3.0.0',
Copy link
Member Author

Choose a reason for hiding this comment

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

@rwjblue what should until be?

Copy link
Member Author

Choose a reason for hiding this comment

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

@rwjblue should I make this page or is this deprecation self-explanatory?

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, good question. This isn't really a deprecation per-se, just a handy warning that a setting that used to matter doesn't any more.

We can either swap this with a warn (instead of deprecate) or leave it as a deprecation and say until: "2.17.0"...

false,
{
id: 'ember-metal.model_factory_injections',
until: '3.0.0',
Copy link
Member Author

Choose a reason for hiding this comment

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

same as above

{
id: 'ember-metal.model_factory_injections',
until: '3.0.0',
url: 'http://emberjs.com/deprecations/v2.x#toc_code-ember-model-factory-injections'
Copy link
Member Author

Choose a reason for hiding this comment

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

same as above

Copy link
Member

@rwjblue rwjblue left a comment

Choose a reason for hiding this comment

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

This is looking good, I'm happy with either deprecate or warn here. If we leave it as deprecate we need to add a section to the website to link to...

if (DEBUG) {
if ('MODEL_FACTORY_INJECTIONS' in ENV) {
deprecate(
'Ember.MODEL_FACTORY_INJECTIONS is no longer required',
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be EmberENV.MODEL_FACTORY_INJECTIONS?

false,
{
id: 'ember-metal.model_factory_injections',
until: '3.0.0',
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, good question. This isn't really a deprecation per-se, just a handy warning that a setting that used to matter doesn't any more.

We can either swap this with a warn (instead of deprecate) or leave it as a deprecation and say until: "2.17.0"...

@stefanpenner
Copy link
Member Author

PR to removing these from blueprints: ember-cli/ember-cli#7025

@stefanpenner stefanpenner force-pushed the model-factory-injections branch 2 times, most recently from 9c18c16 to 277b009 Compare May 4, 2017 22:18
@stefanpenner
Copy link
Member Author

stefanpenner commented May 5, 2017

deprecations PR to website: emberjs/website#2895

@stefanpenner stefanpenner force-pushed the model-factory-injections branch from 277b009 to f71c82d Compare May 5, 2017 18:00
@stefanpenner
Copy link
Member Author

@rwjblue r?

1 similar comment
@stefanpenner
Copy link
Member Author

@rwjblue r?

@stefanpenner
Copy link
Member Author

@rwjblue let me know if this should be [BUGFIX release] or [BUGFIX beta]

@stefanpenner stefanpenner force-pushed the model-factory-injections branch from f71c82d to eb99506 Compare May 9, 2017 22:47
@stefanpenner
Copy link
Member Author

stefanpenner commented May 9, 2017

updated to release as per @rwjblue's suggestion.

@stefanpenner stefanpenner changed the title [BUGFIX] MODEL_FACTORY_INJECTIONS is now always false. [BUGFIX release] MODEL_FACTORY_INJECTIONS is now always false. May 10, 2017
Copy link
Member

@mixonic mixonic left a comment

Choose a reason for hiding this comment

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

This seems great. 👍

Double extend means this flag no longer means what it once did. To ensure ember-data functions correctly, we should now force it to always be false.
@rwjblue rwjblue force-pushed the model-factory-injections branch from eb99506 to 84ba295 Compare May 15, 2017 18:15
@rwjblue rwjblue merged commit 73aef49 into master May 15, 2017
@rwjblue rwjblue deleted the model-factory-injections branch May 15, 2017 21:08
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