vuejs / vue-cli-plugin-vue-next

A Vue CLI plugin for trying out vue-next (experimental)
MIT License
339 stars 23 forks source link

a dozen Vue.use statements were stripped from my main.js #28

Closed vesper8 closed 4 years ago

vesper8 commented 4 years ago

I just tried adding this plugin to an existing project to see what would happen. It did a lot of changes, mostly renaming props to use #, changing dependencies in my package.json and making a few changes in my main.js

One change that didn't make any sense to me is that it removed all this:

Vue.use(BootstrapVue);
Vue.use(Notifications);
Vue.use(ToggleButton);
Vue.use(VueChatScroll);
Vue.use(VueCookie);
Vue.use(VueFormGenerator);
Vue.use(VueLazyload);
Vue.use(VueSweetalert2);
Vue.use(VueGeolocation);
Vue.use(vClickOutside);
Vue.use(device);
Vue.use(PortalVue);

while leaving:

import BootstrapVue from 'bootstrap-vue';
import Notifications from 'vue-notification';
import ToggleButton from 'vue-js-toggle-button';
import VueChatScroll from 'vue-chat-scroll';
import VueCookie from 'vue-cookie';
import VueFormGenerator from 'vue-form-generator';
import VueLazyload from 'vue-lazyload';
import VueSweetalert2 from 'vue-sweetalert2';
import vClickOutside from 'v-click-outside';
import VueGeolocation from '@/plugins/GeoLocation';
import device from 'vue-device-detector';
import PortalVue from 'portal-vue';

Is this right? are imports now sufficient and you no longer need to add Vue.use ?

haoqunjiang commented 4 years ago

There's no Vue.use in Vue 3. So the signature of third-party plugins needs some change. Per the experience from vue-router & vuex, a possible new API is like app.use(router) where router used to be a root component option in Vue 2.

At the time of developing this plugin, I assume users only use the core packages as most third-party libraries haven't been upgraded to Vue 3. So I wrote a straightforward codemod to strip Vue.use and turn root options to app.use().

This is no longer correct though. As of vuetify@next, app.use still expects .use(Vuetify). I'll fix the code logic in the next version.

mariusa commented 4 years ago

@sodatea ping for next version fix? Hope all is good with you in China?

haoqunjiang commented 4 years ago

Thanks for reminding me. I'm busy with some personal stuff and will be off for the next few days. I may have the time to fix the bugs later next week.

Meanwhile, it's hard to get everything right for a plugin that is invoked after the project scaffolding, considering there may be unexpected third-party libraries that are not supported. So I'm working on a PR to directly create Vue 3 projects with Vue CLI https://github.com/vuejs/vue-cli/pull/5637 Hopefully it will be included in the mid-July release. People will no longer need this plugin after that release.