vuejs / component-compiler-utils

Lower level utilities for compiling Vue single file components
321 stars 75 forks source link

add vue-template-compiler as a peer dependency #3

Closed DeMoorJasper closed 6 years ago

DeMoorJasper commented 6 years ago

If vue-template-compiler is not included but you try to parse anything it throws an error saying it can't be found. Adding it as a peer dependency would prevent this. as discussed in https://github.com/parcel-bundler/parcel/pull/1052

yyx990803 commented 6 years ago

This is an interesting case - so the idea is, instead of making vue-template-compiler a peer dep of this package, it should be a peer dep of whatever higher-level package that is using this package.

Take vue-loader for an example: vue-template-compiler is a peer dep of vue-loader because when users use webpack + vue-loader, they need to be able to specify the version of vue-template-compiler in their package.json so that it matches the version of vue they are using. If this package mandates vue-template-compiler as a peer dep, and the version is compatible with what the user wants to use, then it becomes a problem.

I will change the parse API to also take the compiler via options instead (and attempt to require vue-template-compiler if not passed, so that it's backwards compatible).