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

Implicit dependency on vue-template-compiler #297

Closed
pi0 opened this issue May 9, 2019 · 6 comments · Fixed by #298
Closed

Implicit dependency on vue-template-compiler #297

pi0 opened this issue May 9, 2019 · 6 comments · Fixed by #298

Comments

@pi0
Copy link

pi0 commented May 9, 2019

Version

v5.3.0

Reproduction link

nuxt/vercel-builder#42

Steps to reproduce

What is expected ?

What is actually happening?

Additional comments?

This module has an implicit dependency on vue-template-compiler here. All direct dependencies like this should be specified in dependencies section of package.json. When using nuxt-start (a serverless) build of nuxt, this dependency is not available.

It is also better to only require build related deps on build:before nuxt hook to prevent additional overhead when running in production mode.

This bug report is available on Nuxt community (#c237)
@rchl
Copy link
Collaborator

rchl commented May 9, 2019

This code that uses vue-template-compiler is running when generating extra locale routes and Nuxt generates routes in this order:

  • generate default routes
  • call build:extendRoutes hook
  • add routes returned from options.router.extendRoutes functions (if defined)

This module uses ModuleContainer.extendRoutes(fn) to hook into processing of options.router.extendRoutes.

So even when not actually using a hook (because build:extendRoutes would happen at wrong time for this module anyway), I think it's OK to keep using ModuleContainer.extendRoutes(fn) as then the function shouldn't be called on start of built app, right? We'd just need to make the import dynamic so it's not required at top level of the module.

@rchl
Copy link
Collaborator

rchl commented May 9, 2019

@pi0 you think #298 is a good solution to both problems?

@pi0
Copy link
Author

pi0 commented May 9, 2019

@rchl yes, that totally makes sense. Thanks for the PR.

paulgv pushed a commit that referenced this issue May 9, 2019
Also only require makeRoutes when actually building app.
@rchl
Copy link
Collaborator

rchl commented May 13, 2019

@pi0 @paulgv I have just noticed a problem with this change.

With nuxt@2.4.5 version at least, I see this error when trying to build:

Vue packages version mismatch:

- vue@2.6.7 (/Users/user/workspace/my-app/node_modules/vue/dist/vue.runtime.common.js)
- vue-template-compiler@2.6.10 (/Users/user/workspace/my-app/node_modules/nuxt-i18n/node_modules/vue-template-compiler/package.json)

This may cause things to work incorrectly. Make sure to use the same version for both.
If you are using vue-loader@>=10.0, simply update vue-template-compiler.
If you are using vue-loader@<10.0 or vueify, re-installing vue-loader/vueify should bump vue-template-compiler to the latest.


  Error:

  Vue packages version mismatch:

  - vue@2.6.7 (node_modules/vue/dist/vue.runtime.common.js)
  - vue-template-compiler@2.6.10 (node_modules/nuxt-i18n/node_modules/vue-template-compiler/package.json)

  This may cause things to work incorrectly. Make sure to use the same version for both.
  If you are using vue-loader@>=10.0, simply update vue-template-compiler.
  If you are using vue-loader@<10.0 or vueify, re-installing vue-loader/vueify should bump vue-template-compiler to the latest.

  at Object.<anonymous> (node_modules/nuxt-i18n/node_modules/vue-template-compiler/index.js:10:9)
  at Generator.next (<anonymous>)
  at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)


   ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
   │                                                                                                                                                    │
   │   ✖ Nuxt Fatal Error                                                                                                                               │
   │                                                                                                                                                    │
   │   Error:                                                                                                                                           │
   │                                                                                                                                                    │
   │   Vue packages version mismatch:                                                                                                                   │
   │                                                                                                                                                    │
   │   - vue@2.6.7 (/Users/user/workspace/my-app/node_modules/vue/dist/vue.runtime.common.js)                                                 │
   │   - vue-template-compiler@2.6.10 (/Users/user/workspace/my-app/node_modules/nuxt-i18n/node_modules/vue-template-compiler/package.json)   │
   │                                                                                                                                                    │
   │   This may cause things to work incorrectly. Make sure to use the same version for both.                                                           │
   │   If you are using vue-loader@>=10.0, simply update vue-template-compiler.                                                                         │
   │   If you are using vue-loader@<10.0 or vueify, re-installing vue-loader/vueify should bump vue-template-compiler to the latest.                    │
   │                                                                                                                                                    │
   │                                                                                                                                                    │
   ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

It seems like versions of vue and vue-template-compiler must match exactly. I think this line is responsible for that: https://github.com/vuejs/vue/blob/1137e415c9e8701d1b0a25e5812f8c4dffeeeaaa/packages/vue-template-compiler/package.json#L29

Given that vue comes from nuxt, I don't know how to ensure that those are always synchronized. Any idea?

@pi0
Copy link
Author

pi0 commented May 13, 2019

@rchl we can come back to implicit dependency and either:

  • only require for build time
  • or use this.nuxt.resolver.requireModule to require vue-template-compiler.

@rchl
Copy link
Collaborator

rchl commented May 13, 2019

@pi0 thanks. Created #305. Please double check I did the right thing.

paulgv added a commit that referenced this issue May 13, 2019
…#305)

fix: remove explicit dependency on vue-template-compiler (fixes #297)
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 a pull request may close this issue.

2 participants