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

fix(netlify, vercel): explicit server rendering with disabled cache/swr #829

Merged
merged 1 commit into from
Jan 11, 2023

Conversation

danielroe
Copy link
Member

πŸ”— Linked issue

❓ 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

At the moment if you have a default cache rule, you can't override it negatively at a more specific level.

This PR should resolve that.

πŸ“ Checklist

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

@danielroe danielroe added the bug Something isn't working label Jan 11, 2023
@danielroe danielroe requested a review from pi0 January 11, 2023 10:05
@danielroe danielroe self-assigned this Jan 11, 2023
@codecov
Copy link

codecov bot commented Jan 11, 2023

Codecov Report

Merging #829 (c074de2) into main (e12dae1) will increase coverage by 0.10%.
The diff coverage is 90.62%.

@@            Coverage Diff             @@
##             main     #829      +/-   ##
==========================================
+ Coverage   69.83%   69.93%   +0.10%     
==========================================
  Files          57       57              
  Lines        5291     5312      +21     
  Branches      586      594       +8     
==========================================
+ Hits         3695     3715      +20     
  Misses       1588     1588              
- Partials        8        9       +1     
Impacted Files Coverage Ξ”
src/presets/vercel.ts 77.31% <86.36%> (+0.20%) ⬆️
src/presets/netlify.ts 61.76% <100.00%> (+1.39%) ⬆️
src/options.ts 86.37% <0.00%> (+0.57%) ⬆️

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
Collaborator

atinux commented Jan 11, 2023

([_, value]) =>
value.cache === false ||
(value.cache && value.cache.swr === false) ||
(value.cache && (value.cache?.static || value.cache?.swr))
Copy link
Member

@pi0 pi0 Jan 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be simplified for swr check only: !value.cache || !value.cache.swr


Asking ChatGPT: πŸ€“

image

image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that simplification is right:

  1. it drops a check for static
  2. we do care whether cache is explicitly false, in which case we want to write the rule, but if it's undefined we shouldn't force server rendering, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. The main problem is that we are not deeply normalizing the route rules at the moment and with undifined conditions, such simplification is wrong. Cache should be either false or an object. And I'm thinking the static flag could be moved outside. Lets improve later.

Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for vercel hotfix. But we really need to improve cache<>builder mapping system and make it generic and better testable in the future...

@pi0 pi0 merged commit bece791 into main Jan 11, 2023
@pi0 pi0 deleted the fix/shadowed-cache branch January 11, 2023 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants