From fd3f72f4c7388b1f255a0e50357133bbd80588ea Mon Sep 17 00:00:00 2001 From: Eden Sun Date: Thu, 16 Jun 2016 09:55:58 +0800 Subject: [PATCH 1/3] shold emit webpack Error rather than throwing --- lib/template-loader.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/template-loader.js b/lib/template-loader.js index af3d6e083..8668bc53e 100644 --- a/lib/template-loader.js +++ b/lib/template-loader.js @@ -5,6 +5,7 @@ var extname = require('path').extname module.exports = function (content) { this.cacheable && this.cacheable() var callback = this.async() + var emitError = this.emitError var opt = loaderUtils.parseQuery(this.query) var vue = this.options.vue if (vue && vue.template) { @@ -27,10 +28,10 @@ module.exports = function (content) { } if (!cons[opt.engine]) { - throw new Error( + emitError(new Error( 'Template engine \'' + opt.engine + '\' ' + 'isn\'t available in Consolidate.js' - ) + )) } // for relative includes @@ -38,7 +39,7 @@ module.exports = function (content) { cons[opt.engine].render(content, opt, function (err, html) { if (err) { - throw err + emitError(err) } exportContent(html) }) From c7916f3813c596220b848a9fe66c6e0a70fce78b Mon Sep 17 00:00:00 2001 From: Eden Sun Date: Thu, 16 Jun 2016 11:04:31 +0800 Subject: [PATCH 2/3] just callback can emit the error --- lib/template-loader.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/template-loader.js b/lib/template-loader.js index 8668bc53e..9d2f084dc 100644 --- a/lib/template-loader.js +++ b/lib/template-loader.js @@ -5,7 +5,6 @@ var extname = require('path').extname module.exports = function (content) { this.cacheable && this.cacheable() var callback = this.async() - var emitError = this.emitError var opt = loaderUtils.parseQuery(this.query) var vue = this.options.vue if (vue && vue.template) { @@ -28,7 +27,7 @@ module.exports = function (content) { } if (!cons[opt.engine]) { - emitError(new Error( + callback(new Error( 'Template engine \'' + opt.engine + '\' ' + 'isn\'t available in Consolidate.js' )) @@ -39,8 +38,9 @@ module.exports = function (content) { cons[opt.engine].render(content, opt, function (err, html) { if (err) { - emitError(err) + callback(err) + } else { + exportContent(html) } - exportContent(html) }) } From 756bd04c043380fa7cb660aca4f39fcef00b30b2 Mon Sep 17 00:00:00 2001 From: Eden Sun Date: Thu, 16 Jun 2016 11:40:47 +0800 Subject: [PATCH 3/3] should return --- lib/template-loader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/template-loader.js b/lib/template-loader.js index 9d2f084dc..fe7461719 100644 --- a/lib/template-loader.js +++ b/lib/template-loader.js @@ -27,7 +27,7 @@ module.exports = function (content) { } if (!cons[opt.engine]) { - callback(new Error( + return callback(new Error( 'Template engine \'' + opt.engine + '\' ' + 'isn\'t available in Consolidate.js' ))