Skip to content

Commit ceae620

Browse files
committed
raise warnings in the main loader only
1 parent be92a6a commit ceae620

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

lib/loader.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,16 @@ module.exports = function (content) {
135135
}
136136
}
137137

138-
var parts = parse(content, fileName, this.emitError)
138+
var parts = parse(content, fileName)
139139
var hasLocalStyles = false
140140
var output = 'var __vue_script__, __vue_template__\n'
141141

142+
// check if there are any template syntax errors
143+
var templateWarnings = parts.template.length && parts.template[0].warnings
144+
if (templateWarnings) {
145+
templateWarnings.forEach(this.emitError)
146+
}
147+
142148
// add requires for src imports
143149
parts.styleImports.forEach(function (impt) {
144150
if (impt.scoped) hasLocalStyles = true

lib/parser.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ var deindent = require('de-indent')
77
var splitRE = /\r?\n/g
88
var emptyRE = /^\s*$/
99

10-
module.exports = function (content, filename, warn) {
10+
module.exports = function (content, filename) {
1111

1212
var cacheKey = hash(filename + content)
1313
// source-map cache busting for hot-reloadded modules
@@ -31,6 +31,7 @@ module.exports = function (content, filename, warn) {
3131
var lang = getAttribute(node, 'lang')
3232
var src = getAttribute(node, 'src')
3333
var scoped = getAttribute(node, 'scoped') != null
34+
var warnings = null
3435

3536
if (!output[type]) {
3637
return
@@ -78,7 +79,7 @@ module.exports = function (content, filename, warn) {
7879
if (type === 'template') {
7980
node = node.content
8081
if (!lang) {
81-
validateTemplate(node, content, warn)
82+
warnings = validateTemplate(node, content)
8283
}
8384
}
8485

@@ -129,7 +130,8 @@ module.exports = function (content, filename, warn) {
129130
lang: lang,
130131
scoped: scoped,
131132
content: result,
132-
map: map.toJSON()
133+
map: map.toJSON(),
134+
warnings: warnings
133135
})
134136
})
135137

lib/selector.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module.exports = function (content) {
66
this.cacheable()
77
var query = loaderUtils.parseQuery(this.query)
88
var filename = path.basename(this.resourcePath)
9-
var parts = parse(content, filename, this.emitError)
9+
var parts = parse(content, filename)
1010
var part = parts[query.type][query.index]
1111
this.callback(null, part.content, part.map)
1212
}

0 commit comments

Comments
 (0)