Lazy Development JS bundling #28137
Replies: 12 comments 26 replies
-
Hi! in my case, running with Lazy Development flags provides no visible benefits. My codebase is ~6000 lines. TypeScript. |
Beta Was this translation helpful? Give feedback.
-
This is great! Our site is pretty big (~117k lines of js) and our development build averages 260s - 300s
|
Beta Was this translation helpful? Give feedback.
-
👋 Thanks for creating this - really excited to see where this lands! Sharing my experience before/after. Both bootup time and clicking between pages showed regressions, but happy to help provide any more context. TLDR (boot time)Before: 96.657sAfter: 100.425s NavigationBefore: Near instantaneousAfter: 6.533s BeforeCold-start
AfterCold-start. Removed
Clicking a link took about 6 seconds to generate/change:
|
Beta Was this translation helpful? Give feedback.
-
@KyleAMathews Thanks for the response! I've included what I saw with the flag changes below. I've also reached out to our security team about providing you access to the repo and will follow-up with that shortly. One item to note is that this line:
showed up several dozen times while booting.
|
Beta Was this translation helpful? Give feedback.
-
some improvements based on today's discussions #28249 |
Beta Was this translation helpful? Give feedback.
-
I'll push something to prevent this from printing more than once. |
Beta Was this translation helpful? Give feedback.
-
@KyleAMathews GATSBY_EXPERIMENTAL_LAZY_DEVJS=true gatsby develop = Building development bundle - 11.783s Open localhost = Re-building development bundle - 2.553s Experience is a little bit odd to be honest, app is frozen for rebuild time. |
Beta Was this translation helpful? Give feedback.
-
So news — we decided this experiment isn't working out as well as we hoped. Huge thanks to everyone who's tested and given us access to your sites — that's what let us quickly make the decision. The root problem is that for many sites, the wait to navigate between pages when you have to wait for that page to be compiled is really long — like 10s+ — which felt like an unacceptable regression from the current experience. You often want to be able to quickly click around a site and this change breaks it. We looked into a number of workarounds but there just wasn't anything practical that we could figure out. We also saw a few sites where compiling a page component had side effects e.g. they required CSS which they then expected to be part of the global CSS. So introducing this feature would mean some subset of people would see their dev environment work in strange ways depending on which pages they visit. Also we have another change coming soon which seems like a better all-around solution. We're going to be revamping how caching works with Gatsby. Currently when you edit your gatsby-config/gatsby-node files or install a plugin, it deletes all your caches. Including the webpack cache. Which is way too aggressive. So we'll be shipping behind a flag soon a change to this behavior where we'll be much more selective about when we clear the webpack cache which will mean that most times you start the develop server, it'll rely on the webpack cache vs. now where it often has to recreate the same cache. That + the move to webpack 5 in Gatsby v3 (which has a much better cache) will mean that webpack's contributions to dev server starts should be tolerable. |
Beta Was this translation helpful? Give feedback.
-
For people looking to test additional ways to speedup starting the dev server — please try out Query on Demand! We've seen some pretty dramatic speedups for sites with it enabled — #27620 We'd love to have some more testers so we can get this polished up for a full-release. |
Beta Was this translation helpful? Give feedback.
-
Reposting from another discussion.
I was hoping for a way to defer the expensive loader until you actually visit the page. |
Beta Was this translation helpful? Give feedback.
-
Build time notes for covidtracking.com, website code repo is open source. Heres' the timing of Before: 64.198s Clicking around the site is extremely slow, around 10-15 seconds. |
Beta Was this translation helpful? Give feedback.
-
Hey! Sorry to butt in, I'm very new to Gatsby (literally 3 days ago I started) and very new to JS in general (I didn't even know what a component was until I had to add something to my site. I still don't know to be honest!) And this is so big for me! Thank you for doing this I normally make a small change, This cuts down my build time from 78s to 30.2 seconds!! I can now, quite literally, bruteforce editing my website in half the time. Thank you, thank you, thank you!!! One thing I'll say (that may not be obvious to others) but to run this you can use:
In the Terminal. Not sure if it's supposed to be in a settings file somewhere, but this worked great! |
Beta Was this translation helpful? Give feedback.
-
Update
After extensive testing, we've decided to not go ahead with with this experimental feature. See #28137 (comment) for more details.
Huge thanks to everyone who helped test & discuss.
This is an umbrella issue for discussing the new feature for lazy JS bundling in development. The initial PR dropped times for bundling by up to 80% on some sites (with possible future improvements that can be made as well). Sites with less JS won't see as dramatic of improvement but all sites will benefit.
How to test & help out
Try out the feature on your site by running
gatsby develop
with the feature enabledGATSBY_EXPERIMENTAL_LAZY_DEVJS=true gatsby develop
Report any errors or other problems you might see. Also how does it feel clicking around the site? This change will make it slower the first time you visit a page as it compiles each page's code on demand.
We'd love also for you to report on how much this improves times for your site.
To make the comparison, run develop on your site with and without this feature running
gatsby clean
before each run.Beta Was this translation helpful? Give feedback.
All reactions