Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 9 commits into from
Oct 11, 2022

Conversation

danielroe
Copy link
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.

@codecov
Copy link

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