vercel-builder icon indicating copy to clipboard operation
vercel-builder copied to clipboard

Does not support async Nuxt config at runtime

Open danielroe opened this issue 4 years ago • 5 comments

This module supports async nuxt config when building the lambda, but an async function which returns a config at runtime is not supported in this builder. (In general this would be an anti-pattern for a serverless function.)

This issue is to collect the use cases for an async function.

danielroe avatar Sep 08 '21 07:09 danielroe

@danielroe yup sure.

In general my requirements are that I need some async requests for loading configuration, (app config, styling config for tailwind, and other modules, ... ) from a cms ( axios request ). In addition to that also some other axios requests for sitemap information, etc.

So a lot of stuff that I would need before I can export the nuxt.config. :)

Is there still a way to go with Vercel SSR and the builder ? :)

lukas-a-brand avatar Sep 08 '21 08:09 lukas-a-brand

@lukas-a-brand Do you need to do that per-request or only on the initial build?

danielroe avatar Sep 08 '21 08:09 danielroe

@danielroe certainly only initially, per build.

lukas-a-brand avatar Sep 08 '21 08:09 lukas-a-brand

@lukas-a-brand I'd certainly recommend a buildModule that fetches your configuration and then injects all the other build modules with the correct configuration, as well as modifying any other nuxt options. You will find it hugely improves your cold start performance.

danielroe avatar Sep 08 '21 08:09 danielroe

@danielroe oh, I see, so with the build module async operations and data fetching / conversions are no problem, and also giving the data fetched to other modules in the nuxt config ? (https://nuxtjs.org/docs/2.x/directory-structure/modules#async-modules <-- I guess ? ) How can I then as best practice share the data with the rest of the nuxt.config.js ? )

Also another use case: Is there also a possibility to prefill the nuxt store with data in a build module by any chance ? ( or with a normal module, because this data could very well change during the applicaiton lifetime )

lukas-a-brand avatar Sep 08 '21 10:09 lukas-a-brand