Skip to content
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

Does not detect 2.7 accurately when exception is thrown #2017

Open
thedamon opened this issue Nov 19, 2022 · 0 comments
Open

Does not detect 2.7 accurately when exception is thrown #2017

thedamon opened this issue Nov 19, 2022 · 0 comments

Comments

@thedamon
Copy link

Version

15.10.1

Reproduction link

codesandbox.io

Steps to reproduce

Use Vue 2.7 and throw a dependency configuration related exception from loadFromContext internal method (in our case we'd forced a specific package version of nanoid to appease a vulnerability scan).

What is expected?

Vue version should be resolved as 2.7
Exception should be logged

What is actually happening?

Vue-loader determines we are using Vue 2.6 or lower and does not compile script setup blocks and no exception is logged


https://github.com/vuejs/vue-loader/blob/v15.10.1/lib/compiler.js#L21

exports.resolveCompiler = function (ctx, loaderContext) {
  if (cached) {
    return cached
  }

  // check 2.7
  try {
    const pkg = loadFromContext('vue/package.json', ctx)
    const [major, minor] = pkg.version.split('.')
    if (major === '2' && Number(minor) >= 7) {
      return (cached = {
        is27: true,
        compiler: loadFromContext('vue/compiler-sfc', ctx),
        templateCompiler: undefined
      })
    }
  } catch (e) {}

Not sure the rationale for the empty catch block here, but perhaps at least errors should be printed? I'll definitely grant that specific resolutions in package.json are buyer-beware, but I do wonder the rationale behind swallowing any errors. Does an error likely mean you are on vue 2.6 or lower? In my case it did not as the exception was totally unrelated to my version of vue.

The minimal repro really only shows the package.json override and doesn't replicate the issue. I spend a long time trying to cobble together the correct versions of things in a code sandbox but I simply did not have time. If there is a "minimal vue 2.7 repro base" somewhere I can totally modify it but what I found on codesandbox was generally out of date. I hope that the description of the issue is fairly straightforward. we had this issue a long time ago and i wanted to report it but couldn't because 15.10.1 was not tagged and my issue submitted without using the issue helper got closed.

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

No branches or pull requests

1 participant