Skip to content

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

Closed
wants to merge 3 commits into from

Conversation

sunlei33
Copy link

@sunlei33 sunlei33 commented Mar 9, 2017

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.

Copy link
Member

@kazupon kazupon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 👍

Copy link
Member

@znck znck left a 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.

@kazupon kazupon requested a review from yyx990803 March 9, 2017 05:08
@@ -58,6 +58,12 @@ module.exports = function (html) {
options.transformToRequire
)
}
var compilerVersion = require('vue-template-compiler/package.json').version
var vueVersion = require('vue').version
Copy link
Member

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.

Copy link
Author

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

var vueVersion = require('vue').version

if (vueVersion !== compilerVersion) {
this.emitError(`vue version ${vueVersion} mismatch vue-template-compiler version ${compilerVersion}`)
Copy link
Member

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

Copy link
Author

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
@yyx990803
Copy link
Member

After testing this locally, I'm actually not sure if this is better - this change requires removing the version check in vue-template-compiler, but that also means when it is used in other contexts other than vue-loader it would no longer enforce correct versions.

Either way, the user would need to install the correct versions.

@yyx990803 yyx990803 closed this Mar 23, 2017
@alamin3000
Copy link

@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.

@yyx990803
Copy link
Member

@alamin3000 if you don't know how to pin versions, just do a fresh install.

@alamin3000
Copy link

@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.

@yyx990803
Copy link
Member

@alamin3000 In that case your module should list Vue and vue-template -compiler as peer deps

@alamin3000
Copy link

alamin3000 commented Apr 2, 2017

@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.

@alamin3000
Copy link

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.

@yyx990803
Copy link
Member

You are listing them as dependencies, not peerDependencies.

@alamin3000
Copy link

peerDependencies what now!?# I didn't know it existed. Okay I will read on it and try to implement that. Thanks @yyx990803

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants