Commit fdd03380 authored by Evan You's avatar Evan You

fix: relay correct error message on vue-template-compiler version mismatch

parent 9beed01b
......@@ -14,14 +14,18 @@ const { NS } = require('./plugin')
let errorEmitted = false
function loadTemplateCompiler () {
function loadTemplateCompiler (loaderContext) {
try {
return require('vue-template-compiler')
} catch (e) {
throw new Error(
`[vue-loader] vue-template-compiler must be installed as a peer dependency, ` +
`or a compatible compiler implementation must be passed via options.`
)
if (/version mismatch/.test(e.toString())) {
loaderContext.emitError(e)
} else {
loaderContext.emitError(new Error(
`[vue-loader] vue-template-compiler must be installed as a peer dependency, ` +
`or a compatible compiler implementation must be passed via options.`
))
}
}
}
......@@ -62,7 +66,7 @@ module.exports = function (source) {
const descriptor = parse({
source,
compiler: options.compiler || loadTemplateCompiler(),
compiler: options.compiler || loadTemplateCompiler(loaderContext),
filename,
sourceRoot,
needMap: sourceMap
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment