End stream, emit error and update npm dependencies

Now it: 
* ends stream on write
* emits error when the requirejs error callback is called
* works with updated npm dependencies