From bbe310c581c6dc161f87ea6c138cfa3f9c4441c2 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Sun, 6 Sep 2020 23:38:33 +0800 Subject: [PATCH 1/4] fix: don't modify the webpack config if the project's on Vue CLI >= 4.5 And also fixes the runtime alias, as mentioned at https://github.com/vuejs/vue-devtools/issues/1244#issuecomment-687797141 --- index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 529eaf7..02d5264 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,11 @@ module.exports = (api, options) => { + try { + api.assertVersion('< 4.5.0') + } catch (e) { + console.warn(`vue-cli-plugin-vue-next is no longer needed for Vue 3 support, please remove it from the dependencies.`) + return + } + const vueLoaderCacheConfig = api.genCacheConfig('vue-loader', { 'vue-loader': require('vue-loader/package.json').version, '@vue/compiler-sfc': require('@vue/compiler-sfc/package.json').version @@ -10,7 +17,7 @@ module.exports = (api, options) => { 'vue$', options.runtimeCompiler ? 'vue/dist/vue.esm-bundler.js' - : '@vue/runtime-dom' + : 'vue/dist/vue.runtime.esm-bundler.js' ) config.module From 33ae2811ab380bde7585f2155e0e0eb626e66151 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Fri, 11 Sep 2020 15:37:27 +0800 Subject: [PATCH 2/4] fix: do not blindless remove `Vue.use` statements Fixes #28 Note: the end result is still not valid Vue 3 code. But at least it doesn't introduce unintended changes. --- generator/codemods/global-api/remove-vue-use.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/generator/codemods/global-api/remove-vue-use.js b/generator/codemods/global-api/remove-vue-use.js index 119e085..cac39d6 100644 --- a/generator/codemods/global-api/remove-vue-use.js +++ b/generator/codemods/global-api/remove-vue-use.js @@ -22,5 +22,18 @@ module.exports = function removeVueUse({ j, root }) { } } }) - vueUseCalls.remove() + + const removablePlugins = ['VueRouter', 'Vuex'] + const removableUseCalls = vueUseCalls.filter(({ node }) => { + if (j.Identifier.check(node.arguments[0])) { + const plugin = node.arguments[0].name + if (removablePlugins.includes(plugin)) { + return true + } + } + + return false + }) + + removableUseCalls.remove() } From 7b3194046f0d3db230d6e9a061a3ee4b6c08fbc3 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Fri, 11 Sep 2020 15:44:04 +0800 Subject: [PATCH 3/4] chore: reword the warning message --- index.js | 5 ++++- package.json | 1 + yarn.lock | 8 ++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 02d5264..1b6c05d 100644 --- a/index.js +++ b/index.js @@ -1,8 +1,11 @@ +const chalk = require('chalk') + module.exports = (api, options) => { try { api.assertVersion('< 4.5.0') } catch (e) { - console.warn(`vue-cli-plugin-vue-next is no longer needed for Vue 3 support, please remove it from the dependencies.`) + console.warn(chalk.red(`Vue CLI now supports Vue 3 by default.`)) + console.warn(chalk.red(`vue-cli-plugin-vue-next is no longer needed, please remove it from the dependencies.`)) return } diff --git a/package.json b/package.json index c27348c..9a1c17a 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "test": "jest" }, "dependencies": { + "chalk": "^4.1.0", "vue-loader": "^16.0.0-alpha.3" }, "peerDependencies": { diff --git a/yarn.lock b/yarn.lock index ae98141..671dfab 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1455,6 +1455,14 @@ chalk@^3.0.0: ansi-styles "^4.1.0" supports-color "^7.1.0" +chalk@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.0.tgz#4e14870a618d9e2edd97dd8345fd9d9dc315646a" + integrity sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A== + dependencies: + ansi-styles "^4.1.0" + supports-color "^7.1.0" + ci-info@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-2.0.0.tgz#67a9e964be31a51e15e5010d58e6f12834002f46" From 121c571accf5b486d4e8e360ce7848d8c4d6c67d Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Fri, 11 Sep 2020 15:44:21 +0800 Subject: [PATCH 4/4] 0.1.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9a1c17a..186c62f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue-cli-plugin-vue-next", - "version": "0.1.3", + "version": "0.1.4", "description": "Vue CLI plugin for trying out vue-next (experimental)", "main": "index.js", "repository": {