From 7e5862c3bdf74759069cdb3d53f6e4bc17e3c643 Mon Sep 17 00:00:00 2001 From: Evan You Date: Mon, 6 Aug 2018 22:02:05 -0400 Subject: [PATCH] refactor: remove vue-template-compiler from peer dep --- lib/index.js | 13 ++++++++++++- package.json | 3 +-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/index.js b/lib/index.js index 21be67d4b..5ebe70bea 100644 --- a/lib/index.js +++ b/lib/index.js @@ -14,6 +14,17 @@ const { NS } = require('./plugin') let errorEmitted = false +function loadTemplateCompiler () { + 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.` + ) + } +} + module.exports = function (source) { const loaderContext = this @@ -51,7 +62,7 @@ module.exports = function (source) { const descriptor = parse({ source, - compiler: options.compiler || require('vue-template-compiler'), + compiler: options.compiler || loadTemplateCompiler(), filename, sourceRoot, needMap: sourceMap diff --git a/package.json b/package.json index 9478d2897..eb258edac 100644 --- a/package.json +++ b/package.json @@ -33,8 +33,7 @@ ] }, "peerDependencies": { - "css-loader": "*", - "vue-template-compiler": "^2.0.0" + "css-loader": "*" }, "dependencies": { "@vue/component-compiler-utils": "^2.0.0",