Skip to content

feat(netlify): incremental static regeneration + swr - #540

Merged
danielroe merged 9 commits into
mainfrom
feat/netlify-ttl
Oct 11, 2022
Merged

feat(netlify): incremental static regeneration + swr#540
danielroe merged 9 commits into
mainfrom
feat/netlify-ttl

Conversation

@danielroe

@danielroedanielroe commented Oct 2, 2022

Copy link
Copy Markdown
Member

🔗 Linked issue

resolves#93

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

This PR adapts the netlify preset to support the swr/static route rule for dynamic on-demand builder configuration.

For example, the following config would use builder functions only for the blog & articles routes. The blog routes would be generated only once and then persisted; the articles routes would be regenerated every 360 seconds.

exportdefaultdefineNitroConfig({routes: {'/blog/**': {static: true},'/articles/**': {swr: 360}}})

Here's a deployment using this PR: https://main--melodious-klepon-3a2ccb.netlify.app

Note: we pass the value of swr directly through to ttl but it is expressed in the Netlify docs in seconds and we should likely specify what the number means - e.g. seconds or milliseconds, etc.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@codecov

codecovBot commented Oct 2, 2022

Copy link
Copy Markdown

Codecov Report

Merging #540 (9ad970f) into main (1026edb) will increase coverage by 0.05%.
The diff coverage is 100.00%.

@@ Coverage Diff @@## main #540 +/- ##
==========================================
+ Coverage 66.04% 66.09% +0.05% 
==========================================
Files 55 55 Lines 4049 4056 +7 Branches 437 438 +1 ==========================================
+ Hits 2674 2681 +7 
Misses 1371 1371 Partials 4 4 
Impacted FilesCoverage Δ
src/presets/netlify.ts56.33% <100.00%> (+1.92%)⬆️
src/types/nitro.ts100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@atinux

Copy link
Copy Markdown
Member

I believe seconds makes more sense personally :)

@danielroe
danielroe marked this pull request as draft October 3, 2022 10:05
@danielroedanielroe changed the title feat(netlify): support netlify swr/conditional builderfeat(netlify): incremental static regenerationOct 4, 2022
@danielroedanielroe changed the title feat(netlify): incremental static regenerationfeat(netlify): incremental static regeneration + swrOct 4, 2022
@danielroe
danielroe merged commit 8a82de7 into mainOct 11, 2022
@danielroe
danielroe deleted the feat/netlify-ttl branch October 11, 2022 12:24
Comment threadsrc/runtime/entries/netlify.ts
WinterYukky pushed a commit to WinterYukky/nitro that referenced this pull request Nov 1, 2022
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancementNew feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

netlify-on demand preset

3 participants

@danielroe@atinux@pi0