0

First of all a great framework for SSR based MFEs . I was trying out the Ara / Svelte (Micro App1) / Vue (Micro App 2) / Nuxt JS (Appshell) as described in https://ara-framework.github.io/website/blog/2019/08/27/nuxt-js as well as setup the cluster and proxy as described in the docs https://ara-framework.github.io/website/docs/nova-cluster

In the App shell in the Nuxt App I need to include the client side scripts like this

  head: {
    script: [
      { src: 'http://localhost:3000/public/client.js' },
      { src: 'http://localhost:3001/public/client.js' }
    ]
  }

Is there a better way to discover and load this scripts , similar to the server side part is handled by the proxy and the cluster servers ? The problem with the current approach is I need to know where the nova server client scripts are deployed before hand.

tsukhu
  • 1
  • Ok I looked at your new samples on ara https://github.com/marconi1992/ara-spa-vue/blob/master/spa/src/main.js and I guess we can use the views.json and `loadscript` helper to externalize the client scripts and load them on the `NovaMount` event. – tsukhu Apr 28 '20 at 11:23
  • I was able to use the same logic in a `nuxtjs` sample and use sort of externalized client scripts similar to the sample above and it works https://github.com/tsukhu/ara-sample/commit/b310fbfd6a7af71718b8af7b66f00dc5c706aba9 . However the question is can this be done or accessed from the same cluster server so that we don't need to add this information in two places ? – tsukhu Apr 28 '20 at 11:44

1 Answers1

0

As you describe in the comments, using the NovaMount event is the best approach so far. Unfortunately, there's nothing out of the box to do it without explicitly define the bundle URLs yet.

However, we plan to add a new feature to Nova Proxy to make that easier.

In the getComponent helper, we can use the returnMeta property from the second parameter to return the client script URL in the Hypernova response.

hypernova({
  getComponent (name, { returnMeta }) {
    returnMeta.src = 'http://localhost:3000/public/client.js'
  }
})

We get something like this in the Hypernova response.

{
    "success": true,
    "error": null,
    "results": {
        "example": {
            "name": "Example",
            "HTML": "...",
            "meta": {
                "src": "http://localhost:3000/public/client.js"
            },
            ...
        }
    }
}

We plan to inject that client URL in Nova Proxy when including the Nova views as well.

I created this Github issue where you can follow-up on the feature progress. https://github.com/ara-framework/nova-proxy/issues/10