0
votes

I was studying Javascript / Ember and I was looking into its source codes. https://github.com/emberjs/ember.js/

While I was studying, I found something interesting and I wonder how it works. As you may know, you can get version number of Ember if you type Ember.VERSION in the browser console. I wanted to do in my project so I started searching codes how Ember did it.

I could find

// in packages/ember/lib/index.js
Ember.VERSION = VERSION;
...
// Later exports Ember object

However I can't find how Ember makes it available in window (from browser). I expected they did like... window['Ember'] = Ember or something like that but I couldn't find any similar codes.

I wonder if there is anyone knows how they make Ember object available throughout window. Thank you so much!

1
@Siguza Thank you for the comment :) But I am not sure why this is a possible duplicate... I know what is window and its variable. I just want to know how Ember "assigns" variable to window, since I couldn't find any relevant codes from their source codes. - ryan
Have you read that question and its answer(s)? - Siguza

1 Answers

0
votes

ember-cli-app-version addon can expose your application's name and version info. So you can put your version in your templates via an helper.

The addon also registers the infos to the Ember.libraries so that ember-inspector can understand. You can access the Ember.libraries in a such way:

Ember.libraries._registry.filter(item=>{return item.name==='my-app-name';})[0].version

The addon can give you both package.json information or git describe result.