-
Notifications
You must be signed in to change notification settings - Fork 919
when mismatch version, it is better to fail the loader and webpack show error code #702
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…oader and webpack
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix code style issues.
lib/template-compiler.js
Outdated
@@ -58,6 +58,12 @@ module.exports = function (html) { | |||
options.transformToRequire | |||
) | |||
} | |||
var compilerVersion = require('vue-template-compiler/package.json').version | |||
var vueVersion = require('vue').version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably use vue/package.json
here too to avoid evaluating Vue itself on startup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commit a patch for this PR
lib/template-compiler.js
Outdated
var vueVersion = require('vue').version | ||
|
||
if (vueVersion !== compilerVersion) { | ||
this.emitError(`vue version ${vueVersion} mismatch vue-template-compiler version ${compilerVersion}`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use the same language found here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commit a patch for this PR
fetch version from package.json to avoid evaluating Vue
After testing this locally, I'm actually not sure if this is better - this change requires removing the version check in Either way, the user would need to install the correct versions. |
@yyx990803 How do you expect us to resolve this? I change the vue version that the template compiler was complaining about to 2.2.4, now vue-server-renderer is complaining that it needs the 2.2.6 back.... seriously.... you need to reconsider the patch or some other solution. Thanks. |
@alamin3000 if you don't know how to pin versions, just do a fresh install. |
@yyx990803 Thanks. But I wish everything was as easy as "restart the computer" or reinstalling something. Basically I am trying to create a node module (separate repo from my main app) for Vue based template parser say, vue-template-parser. So it has its own Vue dependency + vue-server-renderer. And the app that will use that library also has vue as its dependencies. I can't make sure/dictate that whoever uses the parser they also need to have EXACT same version of the vue... like 2.4.1 (including the patch version number). At least if it ignored the minor patch numbers I would be little less frustrated. Anyway, hope there is a better solution for this or I'm doing something wrong so I can fix it. |
@alamin3000 In that case your module should list Vue and vue-template -compiler as peer deps |
@yyx990803 I do that. The module works independently. It compiles and renders strings. But issue happens when I try to use that module in exiting app which already has vue as dependency! Then I need to make sure that my app vue matches EXACTLY with the module's vue version. One of the advantage of NPM over others such as bower/ composer (php) is that every module can have same library in with different version. If the loader forces otherwise it breaks the way npm module works. |
Here is the repo. https://github.com/es-compose/es-renderer-vue that uses vue for parsing html. If I use this library in any project that has other vue version (2.4.1) then it will complain. |
You are listing them as dependencies, not peerDependencies. |
peerDependencies what now!?# I didn't know it existed. Okay I will read on it and try to implement that. Thanks @yyx990803 |
instead of checking version in vue-template-compiler runtime, check the version in vue-loader.
when mismatch version, the loader will fail and the webpack will return the error code.