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

[CLEANUP beta] Deprecate owner.inject #19680

Merged
merged 1 commit into from
Aug 22, 2021

Conversation

snewcomer
Copy link
Contributor

@snewcomer snewcomer commented Jul 25, 2021

RFC: emberjs/rfcs#680

See https://github.com/emberjs/rfcs/blob/sn/owner-inject-deprecation/text/0680-implicit-injection-deprecation.md#1-deprecate-implicit-injection-on-target-object for the reasons why we first added the initial deprecation in 3.26.0 and are now adding another deprecation but removing the functionality of app.inject.

  • deprecate ability to inject properties on Ember framework objects
  • Remove infrastructure supporting injection
  • remove deprecations ending in 4.0.0 from [Deprecation]: implicit injections #19358
  • remove blueprint inject function
  • remove all implicit injections in codebase

ref #19617

@snewcomer snewcomer force-pushed the sn/deprecate-owner-inject branch 2 times, most recently from a11ae84 to bd3db85 Compare July 26, 2021 03:58
@mixonic mixonic mentioned this pull request Jul 31, 2021
58 tasks
@snewcomer snewcomer force-pushed the sn/deprecate-owner-inject branch 2 times, most recently from fbbd92b to 2a2ea04 Compare August 9, 2021 02:36
@mixonic
Copy link
Member

mixonic commented Aug 17, 2021

@snewcomer can the cleanup/removal of the old API land in its own PR with [CLEANUP beta]? I worry this has entangled the removals with the addition of a deprecation, but they should not be coupled.

@snewcomer
Copy link
Contributor Author

snewcomer commented Aug 17, 2021

@mixonic So this timeline took me a bit to grep but is laid out in this RFC .

  1. 3.26 and up deprecated the use of implicit injections. See https://deprecations.emberjs.com/v3.x#toc_implicit-injections. So by now, everybody who is using implicit injections has been warned and hopefully made adjustments (including users of ember-data who relied on the implicit store deprecation).
  2. 4.x deprecates owner.inject. In addition, we will remove the supporting infrastructure to manage injections. inject is now effectively now a noop.
  3. 5.x will remove the injection function and supporting code.

Sry if the above was rehashing something you already know. But the deprecation + removal of the supporting infrastructure for inject go hand in hand.

@pzuraq noted we could assert as well. I think that was only if we didn't wrap up the work that is in this PR in time.

this.component = CoreOutlet.create();
let outletTemplateFactory = this.owner.lookup('template:-outlet');
let environment = this.owner.lookup('-environment:main');
this.component = CoreOutlet.create({ environment, template: outletTemplateFactory });
Copy link
Contributor Author

Choose a reason for hiding this comment

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

☝️ this is important to note. This was refactored from the implicit injection.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

working on that now.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

landed and released as @ember/[email protected]

Copy link
Contributor

@pzuraq pzuraq left a comment

Choose a reason for hiding this comment

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

So I believe that _lazyInjections can also be removed as part of this work. As far as I can tell, it's basically creating and setting up lazy versions of implicit injections, only in DEBUG, and I can't see any usage in the ecosystem at all: https://emberobserver.com/code-search?codeQuery=_lazyInjections

It's explicitly marked as a private API as well, so should be fine to remove. Overall this PR looks amazing and once those changes are made, I think we're good to merge!

packages/@ember/-internals/container/lib/registry.ts Outdated Show resolved Hide resolved
packages/@ember/-internals/glimmer/lib/renderer.ts Outdated Show resolved Hide resolved
assertResources('/b', ['/b', '/c']),
assertResources('/c', ['/c']),
assertResources('/d', ['/d', '/e']),
assertResources('/e', ['/e']),
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 don't think the intention here was parallel. So I made it serial. This was also due to the fact that creating a singleton service per app instance that tracked "network" requests in each route was proving difficult when they happen in parallel. Lmk if anybody has any comments here.

@@ -32,7 +32,6 @@ module.exports = {
'_helpers',
'_hydrateUnsuppliedQueryParams',
'_initializersRan',
'_injections',
'_internalReset',
'_invoke',
'_lazyInjections',
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 checked out lazyInjections and it looks like it is used to validate service injections and not implicit.

['@test injecting an unknown service raises an exception']() {

@snewcomer snewcomer changed the title Deprecate owner.inject Deprecate and remove owner.inject Aug 17, 2021
@snewcomer snewcomer changed the title Deprecate and remove owner.inject Deprecate owner.inject Aug 17, 2021
@mixonic
Copy link
Member

mixonic commented Aug 18, 2021

@snewcomer I don't understand the statement:

4.x deprecates owner.inject. In addition, we will remove the supporting infrastructure to manage injections. inject is now effectively now a noop.

Deprecated functionality is not removed, it is merely warned against in development builds.

Do you mean "if a user were to use an explicit injection as suggested by the deprecation message, then any owner.inject based type-based injection for the same property could be safely considered a no-op and removed" or some other phrasing?

edit: Ok, I see what you're going for.

@mixonic mixonic changed the title Deprecate owner.inject [CLEANUP beta] Deprecate owner.inject Aug 18, 2021
{
id: 'remove-owner-inject',
until: '5.0.0',
url: 'https://deprecations.emberjs.com/v3.x#toc_implicit-injections',
Copy link
Member

Choose a reason for hiding this comment

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

This should get a 4.x deprecation entry. The 3.x one is much more information than is probably needed, explains how to move away from APIs which the user already shouldn't be using, and is just confusing as it is in the 3.x series.

Screenshot from 2021-08-19 21-36-13

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

If you can update the link here to point to the correct 4.x deprecation page we can land this PR independent of ember-learn/deprecation-app#932, IMO

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 fixed!

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.

Awesome stuff here @snewcomer !

@mixonic
Copy link
Member

mixonic commented Aug 22, 2021

Force pushed a single commit for a clean history, letting CI run.

@mixonic mixonic merged commit 955a5e6 into emberjs:master Aug 22, 2021
@stefanpenner
Copy link
Member

stefanpenner commented Aug 23, 2021

I believe this currently incompatible with @ember/test-helpers... I'm going to try and add the capability to @ember/test-helpers now, but it will require folks upgrade.

This broke embroider's canary tests: embroider-build/embroider#932


@mixonic My work on embroider has been nontrivially impact due to ember-canary repeatedly breaking other core provided libraries such as @ember/test-helpers / @ember/test-waiters. Is it possible to include additional smoke tests here, maybe super-rentals or something? The PR author tends to have all the required context at the time of this PR to quickly fix those issues, if they where aware of the failure.

Anyways, adding at-least @ember/test-helpers or at-best super-rentals to a smoke test for these deprecations merges would really ease the fallout of these otherwise excellent removals.

@snewcomer
Copy link
Contributor Author

@stefanpenner I would be happy to add this. I love adding this type of regression testing!

stefanpenner added a commit to emberjs/ember-test-helpers that referenced this pull request Aug 23, 2021
ember-canary requires `template` + `environment` be provided to the view. This seems like a reasonable change, but does require “low level” libraries such as `@ember/test-helpers` to make some changes.

(Ember PR emberjs/ember.js#19680)
@stefanpenner
Copy link
Member

@snewcomer awesome. At the very-least, I think ember could get lots of milage out of smoke testing @ember/test-helpers.

@stefanpenner
Copy link
Member

proposed fix for @ember/test-helpers emberjs/ember-test-helpers#1110

@stefanpenner
Copy link
Member

@snewcomer also, if you have cycles a small inline comment in ember.js, specifically around #19680 (comment) to inform authors that changes need to be made in parallel with @ember/test-helpers would be dope.

Ultimately, having ember provide a "public api" for test-helpers to tap into here could prove to be the best long-term solution. But may not be the most pragmatic choice right now.

stefanpenner added a commit to embroider-build/embroider that referenced this pull request Aug 23, 2021
@stefanpenner
Copy link
Member

Fix for my above issue landed as @ember/[email protected]

stefanpenner added a commit to embroider-build/embroider that referenced this pull request Aug 23, 2021
* [fixes #932] fix ember-canary test scenario

description of problem: emberjs/ember.js#19680 (comment)
fix in @ember/test-helpers: emberjs/ember-test-helpers#1110

* [fixes ember-canary/ember-beta] migrate ember-cli-template-lint -> ember-template-lint

Ember-cli-template-lint is deprecated, and now incompatible with ember 4.x
@snewcomer
Copy link
Contributor Author

@stefanpenner This PR to smoke test ember-test-helpers, ember-string and ember-legacy-built-in-components is passing now! Would appreciate a review if you have some time.

#19728

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.

4 participants