Version defined in one place, available everywhere in your app


#1

I just wanted to share this cool little tidbit I figured out tonight.

import { version } from '/package.json';

Now you only have to ever worry about updating your app’s version number in package.json, and it’s easily accessible throughout your code (I display it in a tiny font in the bottom left).


#2

You can do the same for packages you depend on, btw! Definitely a cool trick.


#3

That’s awesome! Coincidentally, you can also do this

import packageJson from '/package.json'

To get the whole package.json structure into a variable. I verified it on https://github.com/trajano/meteor-boilerplate/blob/angular/imports/ui/components/meteorSample.component.js