Fixing the ember-getowner-polyfill deprecation


by Ryan Toronto

Last week when upgrading an older Ember application, I ran into a deprecation that I wasn't quite sure how to fix:

DEPRECATION: ember-getowner-polyfill is now a
true polyfill. Use Ember.getOwner directly instead 
of importing from ember-getowner-polyfill [deprecation 
id: ember-getowner-polyfill.import]

DEPRECATION: ember-getowner-polyfill

I searched my codebase for any reference to ember-getowner-polyfill but couldn't find anything. Turns out it's almost always used by other addons in support of older versions of Ember.

But if your app is on version 2.3 or later, you can drop it completely. So, let's get rid of it.

The deprecation tells us to use Ember.getOwner directly instead of importing the polyfill, so we'll need to find any addons we're using that import that polyfill.

The quickest way to do this is to search our application's node_modules for the import and ember-getowner-polyfill strings — a perfect task for grep and a regular expression:

grep -rE ^import(.*)getowner-polyfill node_modules

This prints out a list of all the addons that rely on the polyfill.

The last step is to upgrade each addon to its latest version. Luckily for me, most addon authors had fixed this deprecation warning months ago, so the rest of the process was easy!

Questions?

Send us a tweet:

Or ask us in Inside EmberMap, our private Slack workspace for subscribers.