vuejs / vue-cli

🛠️ webpack-based tooling for Vue.js Development
https://cli.vuejs.org/
MIT License
29.75k stars 6.33k forks source link

Upgrading to vue-cli@4 may have put dependency in the wrong place #5112

Open kierans opened 4 years ago

kierans commented 4 years ago

Version

4.1.2

Environment info

Environment Info:

  System:
    OS: macOS Sierra 10.12.6
    CPU: (8) x64 Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz
  Binaries:
    Node: 10.16.3 - /opt/local/bin/node
    Yarn: 1.17.3 - /opt/local/bin/yarn
    npm: 6.11.2 - /opt/local/bin/npm
  Browsers:
    Chrome: 79.0.3945.130
    Firefox: Not Found
    Safari: 12.1.2
  npmPackages:
    @vue/babel-helper-vue-jsx-merge-props:  1.0.0 
    @vue/babel-plugin-transform-vue-jsx:  1.1.2 
    @vue/babel-preset-app:  4.1.2 
    @vue/babel-preset-jsx:  1.1.2 
    @vue/babel-sugar-functional-vue:  1.1.2 
    @vue/babel-sugar-inject-h:  1.1.2 
    @vue/babel-sugar-v-model:  1.1.2 
    @vue/babel-sugar-v-on:  1.1.2 
    @vue/cli-overlay:  4.1.2 
    @vue/cli-plugin-babel: ^4.1.2 => 4.1.2 
    @vue/cli-plugin-e2e-nightwatch: ^4.1.2 => 4.1.2 
    @vue/cli-plugin-router:  4.1.2 
    @vue/cli-plugin-typescript: ^4.1.2 => 4.1.2 
    @vue/cli-plugin-unit-mocha: ^4.1.2 => 4.1.2 
    @vue/cli-plugin-vuex:  4.1.2 
    @vue/cli-service: ^4.1.2 => 4.1.2 
    @vue/cli-shared-utils:  4.1.2 
    @vue/component-compiler-utils:  3.1.1 
    @vue/preload-webpack-plugin:  1.1.1 
    @vue/test-utils: 1.0.0-beta.29 => 1.0.0-beta.29 
    @vue/web-component-wrapper:  1.2.0 
    typescript: ^3.4.3 => 3.5.3 
    vue: ^2.6.10 => 2.6.10 
    vue-class-component: ^7.0.2 => 7.1.0 
    vue-hot-reload-api:  2.3.4 
    vue-loader:  15.8.3 
    vue-property-decorator: ^8.1.0 => 8.2.1 
    vue-style-loader:  4.1.2 
    vue-template-compiler: ^2.6.10 => 2.6.10 
    vue-template-es2015-compiler:  1.9.1 
  npmGlobalPackages:
    @vue/cli: 4.1.2

Steps to reproduce

  1. Generate a library project using @vue/cli@3.8.4
  2. Upgrade Vue CLI to 4.1.2
  3. In project dir run vue upgrade --all
  4. core-js is listed as a dependency not a devDepedency (and the original devDependency of core-js isn't removed

What is expected?

When the project is generated via @vue/cli@3.8.4 the devDependencies looks like:

"devDependencies": {
    "@vue/cli-plugin-babel": "^3.10.0",
    "@vue/cli-plugin-e2e-nightwatch": "^3.11.0",
    "@vue/cli-plugin-typescript": "^3.10.0",
    "@vue/cli-plugin-unit-mocha": "^3.10.0",
    "@vue/cli-service": "^3.10.0",
    "core-js": "^2.6.5"
}

I would have expected after the upgrade for the dependencies to be listed in devDependencies only.

What is actually happening?

Package json looks like:

  "dependencies": {
    "core-js": "^3.4.4",
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "^4.1.2",
    "@vue/cli-plugin-e2e-nightwatch": "^4.1.2",
    "@vue/cli-plugin-typescript": "^4.1.2",
    "@vue/cli-plugin-unit-mocha": "^4.1.2",
    "@vue/cli-service": "^4.1.2",
    "core-js": "^2.6.5"
}

Because the upgrade upgraded the Vue CLI modules, I'm assuming core-js is only needed in the build phase and can safely be put manually back into devDependencies. However there may be a bug in how the package.json was updated in the first place.

kierans commented 4 years ago

I've updated the description to recognise that for the particular project I was upgrading it was a library project, so we don't want dependencies like core-js in the final dist as it's up to the library user/app to provide the necessary runtime modules.