asset-pipe-dev-middleware
Advanced tools
Comparing version 1.0.0-alpha.8 to 1.0.0-alpha.9
@@ -24,3 +24,9 @@ 'use strict'; | ||
this.writer.on('update', () => { | ||
this.writer.bundle().pipe(devnull()); | ||
const bundler = this.writer.bundle(); | ||
bundler.on('error', (e) => { | ||
this.emit('error', e); | ||
}); | ||
bundler.pipe(devnull()); | ||
}); | ||
@@ -53,6 +59,19 @@ | ||
js () { | ||
const self = this; | ||
return (req, res) => { | ||
return (req, res, next) => { | ||
res.writeHead(200, { 'Content-Type': 'application/javascript' }); | ||
self.writer.bundle().pipe(res); | ||
const bundler = this.writer.bundle(); | ||
bundler.on('error', cleanup); | ||
const writeStream = bundler | ||
.pipe(res) | ||
.on('error', cleanup); | ||
function cleanup (e) { | ||
res.write(`console.error(${JSON.stringify(e.stack)})`); | ||
bundler.pause(); | ||
bundler.unpipe(writeStream); | ||
writeStream.end(); | ||
next(e); | ||
} | ||
}; | ||
@@ -59,0 +78,0 @@ } |
{ | ||
"name": "asset-pipe-dev-middleware", | ||
"version": "1.0.0-alpha.8", | ||
"version": "1.0.0-alpha.9", | ||
"author": { | ||
@@ -5,0 +5,0 @@ "name": "Trygve Lie", |
3227
59