single-spa / single-spa-vue

a single-spa plugin for vue.js applications
MIT License
182 stars 42 forks source link

feat: allow promise in handleInstance hook #84

Closed lifeart closed 3 years ago

lifeart commented 3 years ago

usage:

  handleInstance: async (app) => {
    app.use(router);
    await router.isReady();
  }

resolves: https://github.com/single-spa/single-spa-vue/issues/83

refs: https://ssr.vuejs.org/guide/routing.html#code-splitting

image

lifeart commented 3 years ago

Hi @joeldenning! Tests added.

I'm little bit confised about this branch of code: https://github.com/single-spa/single-spa-vue/pull/84/files#diff-d3b89dd088913971f21ae339bd0ea76769602c03acb5d9e1efc116efe355bb28R155

there is no mounting and root assigment if we provide Vue as params, instead of createInstance hook.

joeldenning commented 3 years ago

Tests failed when run in Github action - please fix

there is no mounting and root assigment if we provide Vue as params, instead of createInstance hook.

Could you clarify what you mean here? I read the line of code you linked to but am not sure what you mean.

lifeart commented 3 years ago

Sure, there is 2 branches of code:

image

and

image

in first one we have "mount call":

            instance.root = instance.vueInstance.mount(appOptions.el);

and for second, there is no

wondering, will be auto-mounted somehow?

joeldenning commented 3 years ago

In Vue 3, you have to call createApp().mount(), but in Vue 2 you just call new Vue() to mount it. The first code path you shared is for Vue 3, the second code path is for Vue 2.

joeldenning commented 3 years ago

Published in https://github.com/single-spa/single-spa-vue/releases/tag/v2.5.0

joeldenning commented 3 years ago

Documented in https://github.com/single-spa/single-spa.js.org/pull/472