Today I Learned

hashrocket A Hashrocket project

Fastboot proofing your Ember addons...

I've been working a bit on trying to get Ember Weekend working with fastboot (again). The process was halted when I ran into complications around Liquid Fire and its animation dependency lib Velocity.js, which requires that a document be present.

Fastboot uses Simple DOM as its DOM and does not call it document on self (or window). Server side rendering with Fastboot has some limitations around what you are able to do as a result.

In most cases your addons should guard against any document usage with the following guard:

if (typeof document !== 'undefined') {
  // something with document here
}

Yesterday, I put a PR in (which is very much still a WIP) to help make this easier for addon authors who use EmberApp#import to get their dependencies into vendor.js. The idea is to automatically wrap all dependencies imported this way with the guard above. And allow opting-out by specifying preventDOMGuard in your app.import

app.import(this.bowerDirector + '/foo.js', { preventDOMGuard: true });

We'll see how it goes.

See More #emberjs TILs