Comments (4)
Hi @adamthewan,
Thanks for sharing these details! It looks like it's really the Netlify Functions (bundling and uploading to AWS lambda) that is slowing down the build.
Unfortunately, as far as I am aware, there is not much we can do on the next-on-netlify
-side. next-on-netlify
just wraps the Next.js page into a 2kB-handler to make it compatible with Netlify Functions.
Some questions/suggestions/ideas:
- Are you using
target: "experimental-serverless-trace"
innext.config.js
? If you don't have any npm packages that rely on binary code, it's better and faster to usetarget: "serverless"
. There is a way to do a hybrid approach, where you bundle only the binary dependencies and inline all others. Let me know if you're in this situation of having binary dependencies and you're usingexperimental-serverless-trace
and the hybrid approach could be relevant. - Do you need all the dependencies that end up in the Netlify Function? If you open/extract some of your zipped functions, you can navigate to
node_modules
folder inside the zip file and sort by size to see which dependencies use up the most space. Perhaps there are some that you don't actually need for server-side rendering? If so, you can load them client-side only with Next.js' dynamic import — happy to share more, if relevant. - Do all of your routes need to be server-side rendered? Perhaps some of your pages can be pre-rendered using
getStaticProps
rather thangetServerSideProps
orgetInitialProps
. Any prerendered pages do not need a Netlify Function, so you'll reduce the build time. - If you don't necessarily mind the long build time or you are willing to live with it, I believe the Netlify team does have the power to increase the build timeout duration to at least 30 minutes. If you're on a paid plan, probably even longer. See here: https://community.netlify.com/t/extend-15min-max-build-time-to-30min/13033
Does that help? I'm sorry that there is no silver bullet, but hopefully you can shave at least some minutes off the build time this way. 🚀
from next-on-netlify.
Hey @FinnWoelm , thanks for the reply!
-
Yup I am using
target: "experimental-serverless-trace"
. This is because I'm usingfirebase
and for some reason runs into issues usingtarget: "serverless"
. -
This is a good suggestion. Just took a look, looks like the biggest files are:
@material-ui - 63.3mb
pose-core - 60.7mb (from react-pose)
next - 46mb
@firebase - 43.4mb
Will research more on how to make these packages imported dynamically with NextJS.
-
Agreed on this suggestion. Will look more into it. I believe this is a NextJS problem then.
-
Yup, we're on the paid plan. Have sent a message to Netlify customer service to increase it to 30 mins. However, we turn on auto-publishing for our production branch + 5 stage branches. Having our deployment time be 25 mins each wouldn't be scalable.
from next-on-netlify.
Hey @FinnWoelm , thanks for the suggestions. We're now dynamically loading a lot of our packages, and it seems to have made things better! The build time is now only 8 mins without cache, and about half once we have the build cache.
from next-on-netlify.
Great to hear that! 😊
Hopefully, there will be a hybrid serverless mode some day that inlines most dependencies, but allows to keep the dependencies with binaries separate. For example, there is no need to bundle 60MB of material-ui when you're only using a couple MUI components on the page. The standard serverless
figures out what you are really using and inlines only that code. With experimental-serverless-trace
, we end up bundling the entire library.
Let us know if you run into any other issues! Until then, happy hacking 🔥
from next-on-netlify.
Related Issues (20)
- Add tests for root level index pages of all page types for i18n
- Use splats in SSG redirects instead of adding a redirect for every exact prerendered path HOT 5
- Investigate tradeoffs between redirects and copying files [to correct paths] HOT 1
- Netlify post processing/bundling causes some rendering to be blocked HOT 4
- "blocking" on getStaticPaths' fallback throwing ambiguous error HOT 1
- Cannot find module 'critters' HOT 2
- Missing `pages-manifest.json` HOT 1
- Failure when the publish directory is `public`. HOT 1
- Cannot find module 'jimp' HOT 12
- Header config causes CLI to throw "invalid rule: cannot contain anything after *" HOT 7
- _redirects sorted wrong when using catch all route and dynamic routes HOT 4
- Add clarification for deployment with submodules HOT 4
- Cannot find module critters HOT 15
- [i18n] preview redirects are failing with non-default locales HOT 8
- Forward options params to "nextOnNetlify" function from node command-line args HOT 1
- Allow API routes to optionally run as background function HOT 3
- "The 'path' argument must be of type string. Received undefined" when using next-auth HOT 18
- Missing locale files with next-i18next HOT 10
- Timeout error when using MongoDB in getServerSideProps HOT 4
- *** deprecating next-on-netlify *** (info & feedback) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from next-on-netlify.