Skip to content

Commit

Permalink
refactor: remove vue-template-compiler from peer dep
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Aug 7, 2018
1 parent a6028e6 commit 7e5862c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
13 changes: 12 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
]
},
"peerDependencies": {
"css-loader": "*",
"vue-template-compiler": "^2.0.0"
"css-loader": "*"
},
"dependencies": {
"@vue/component-compiler-utils": "^2.0.0",
Expand Down

0 comments on commit 7e5862c

Please sign in to comment.