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!: remove catch-all DSG redirect and handle discretely #334

Merged
merged 6 commits into from
Apr 4, 2022

Conversation

orinokai
Copy link
Contributor

Summary

BREAKING CHANGE: DSG pages are now discretely redirected to the handler function, rather than via a catch-all redirect. This PR removes the catch-all redirect and moves DSG handling to netlify/gatsby-plugin-netlify, making that plugin a requirement for DSG pages.

This change ensures that 404 pages aren't unnecessarily handled via SSR and ensures they work when a site has functions but no SSR/DSG bundle.

Test plan

  1. The demo in the repo isn't able to provide a case for 'Functions but no SSR/DSG', so a new Gatsby test site is needed with that configuration.
  2. 404 page should render successfully without being redirected to the handler function.

Relevant links (GitHub issues, Notion docs, etc.) or a picture of cute animal

Fixes #330

Standard checks:

  • Check the Deploy Preview's Demo site for your PR's functionality
  • Add docs when necessary

🧪 Once merged, make sure to update the version if needed and that it was published correctly.

@orinokai orinokai self-assigned this Mar 25, 2022
@netlify
Copy link

netlify bot commented Mar 25, 2022

Deploy Preview for netlify-plugin-gatsby-demo ready!

Name Link
🔨 Latest commit c07430c
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-gatsby-demo/deploys/624ac605cec0e9000819f5fd
😎 Deploy Preview https://deploy-preview-334--netlify-plugin-gatsby-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

ericapisani
ericapisani previously approved these changes Mar 25, 2022
Copy link
Contributor

@ericapisani ericapisani left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

ascorbic
ascorbic previously approved these changes Mar 28, 2022
Copy link
Contributor

@ascorbic ascorbic left a comment

Choose a reason for hiding this comment

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

Looks good, but let's hold off merging this until netlify/gatsby-plugin-netlify#102 lands

@orinokai orinokai dismissed stale reviews from ascorbic and ericapisani via 06d961d April 1, 2022 15:44
if (!hasPlugin(gatsbyConfig.plugins, 'gatsby-plugin-netlify')) {
if (hasPlugin(gatsbyConfig.plugins, 'gatsby-plugin-netlify')) {
if (
// prettier-ignore
Copy link
Contributor Author

Choose a reason for hiding this comment

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

FYI this ignore is just to avoid tripping over the max-lines lint rule!

Copy link
Contributor

Choose a reason for hiding this comment

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

Why does it need a prettier ignore for that? Isn't that an eslint rule?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the file was under 150 lines until prettier formatted that 1 line onto 3. I tried ignoring prettier to see if it passed the eslint rules and it did, so I just kept it there. I can swap it for the eslint-ignore if you think it makes more sense?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, just do the eslint ignore for max lines for the whole file

name: string,
version: string,
): Promise<boolean> {
const packagePath = findModuleFromBase({
Copy link
Contributor

Choose a reason for hiding this comment

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

I appreciate the desire to reuse the existing funciton, but I think in this situaiton calling require.resolve directly with ${packagePath}/package.json is probably better than using that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fair point, have amended

Copy link
Contributor

@ascorbic ascorbic left a comment

Choose a reason for hiding this comment

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

:shipit:

@kodiakhq kodiakhq bot merged commit 21773dd into main Apr 4, 2022
@kodiakhq kodiakhq bot deleted the rs/dsg-redirects branch April 4, 2022 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

404 pages don't work when a site has Functions but no SSR/DSG pages
3 participants