bluebeel / now-nuxt

A Now v2 Nuxt builder
25 stars 1 forks source link

The lambda function size (130.17mb) exceeds the configured limit (50mb). #10

Closed dohomi closed 5 years ago

dohomi commented 5 years ago

Hello this package always results in the following now error:

The lambda function size (130.17mb) exceeds the configured limit (50mb).

Only the very first build command succeeds. The dependencies are fairly small this should not be the issue. Is there any now command I am overlooking to clean up the size?

bluebeel commented 5 years ago

The size of lambdas on zeit.co are limited to 50mb. It is not possible to go over this one. If the application you have generates a build greater than this size for a lambda, unfortunately you can't use the platform.

dohomi commented 5 years ago

@bluebeel for me it rather seems like a bug. If I deploy without

filenames: {
      app: '[name].js',
      chunk: '[name].js'
}

the deployment succeeds but the website does not work at all, if I the filenames naming I receive the error of function size while building. This is a demo repo to showcase the setup: https://github.com/dohomi/nuxt-storyblok-demo-now

atinux commented 5 years ago

Could you try with nuxt-start @dohomi

nuxt is 60MB installation size nuxt-start is only 8MB

dohomi commented 5 years ago

@Atinux I tried a lot of things - but nothing worked. The bundle size was raising up to 150 MB - I don't know out of what reason. Besides that you can only use this bundle without any webpack config and you have to use the same common and app names without hashes which makes caching unavailable

timothyis commented 5 years ago

I believe this is because webpack in Nuxt will bundle everything as if it's all shared, however, serverless depends on individual entry points. So we need to find a solution for this. I'm talking to @Atinux and the core Nuxt.js team to try and see how we can resolve this!

bluebeel commented 5 years ago

Thanks @timothyis and @Atinux and sorry @dohomi for the delayed response. I really don't have the time for the moment with my studies and without now dev, it's a big hard to debug or improved the builder atm.

@Atinux i was wondering if we could have a serverless target build for nuxt like next.js did.

atinux commented 5 years ago

This is in the backlog of Nuxt.js indeed, it's not that simple since it implied vue-server-renderer refactoring directly. I am also talking to the Vue core team to see how fast we could implement it.

teleyinex commented 5 years ago

Guys, soo cool you are working on this :-) Happy to help, if you need a hand

dohomi commented 5 years ago

@Atinux for a recent client I am working with NextJS and their serverless build. Currently a quite reasonable sized project is ~200Kb lambda size and a the main page index.js ~1.3MB. Not sure how they receive this size though-.. I tried to look for the responsible code making the bundles but currently stuck with too much work.

pi0 commented 5 years ago

Update: Nuxt team are working on an official now2 builder. Lambda size should be reasonably small by properly cleaning up node_modules.

image

image


https://github.com/nuxt/now-builder

dohomi commented 5 years ago

@pi0 great news! Maybe the size could be reduced if some business logic like serverMiddleware could be abonded, in serverless environment I think people would write their own routes for API endpoints. I think ~400ms cold boot is reasonable but will not result in the best pagespeed ranking.

pi0 commented 5 years ago

@dohomi Yes. Things like component LRU-cache or serverMiddleware are not good for serverless. We are trying our best to support and optimize for serverless environments as much as possible but for the best SSR performance, standard/non-serverless deployment is recommended.