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

Single-spa patches $nuxt #1176

Open
lipton-v opened this issue Dec 4, 2023 · 0 comments
Open

Single-spa patches $nuxt #1176

lipton-v opened this issue Dec 4, 2023 · 0 comments

Comments

@lipton-v
Copy link

lipton-v commented Dec 4, 2023

I use Single-spa (v5) and Nuxt (v2). I struggle with i18n. $t - localisation function is called as $nuxt.$t in main-app . After attending sub-app $nuxt is different and $nuxt refers to sub-app. $nuxt.$t is undefined. How to prevent overwriting $nuxt by Single-spa?

Registarting sub-app in main-app:

<template>
  <div>
    <div id="__subapp" key="subapp"></div>
  </div>
</template>

<script>
import { registerApplication, start, getAppNames, unregisterApplication } from "single-spa"

export default {
  created() {
    console.log(window.$nuxt) // window.$nuxt refers to main-app. window.$nuxt.$t is defined
    if(!getAppNames().includes('subapp')){
      registerApplication({
        name: 'subapp',
        app: async () => await import('~/../sub-app/dist/_nuxt/subapp'),
        activeWhen: '/subapp'
      });
      start();
    }
  },
  async beforeDestroy() {
    console.log(window.$nuxt) //  window.$nuxt refers to sub-app. window.$nuxt.$t is undefined
    await unregisterApplication('subapp')
  }
}
</script>

Before

After

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

No branches or pull requests

1 participant