Skip to content

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

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

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

Conversation

@danielroe
Copy link
Copy Markdown
Member

@danielroe danielroe commented Oct 2, 2022

🔗 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.

export default defineNitroConfig({
  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.

@danielroe danielroe added the enhancement New feature or request label Oct 2, 2022
@danielroe danielroe requested a review from pi0 October 2, 2022 13:53
@danielroe danielroe self-assigned this Oct 2, 2022
@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 2, 2022

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 Files Coverage Δ
src/presets/netlify.ts 56.33% <100.00%> (+1.92%) ⬆️
src/types/nitro.ts 100.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

atinux commented Oct 3, 2022

I believe seconds makes more sense personally :)

@danielroe danielroe marked this pull request as draft October 3, 2022 10:05
@danielroe danielroe marked this pull request as ready for review October 4, 2022 08:44
@danielroe danielroe changed the title feat(netlify): support netlify swr/conditional builder feat(netlify): incremental static regeneration Oct 4, 2022
@danielroe danielroe changed the title feat(netlify): incremental static regeneration feat(netlify): incremental static regeneration + swr Oct 4, 2022
@danielroe danielroe merged commit 8a82de7 into main Oct 11, 2022
@danielroe danielroe deleted the feat/netlify-ttl branch October 11, 2022 12:24
Comment thread src/runtime/entries/netlify.ts
WinterYukky pushed a commit to WinterYukky/nitro that referenced this pull request Nov 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

netlify-on demand preset

3 participants