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: clear redirects/rewrites produced by previous builds and generate functions in ntl dev #738

Merged
merged 5 commits into from
Jan 10, 2024

Conversation

pieh
Copy link
Contributor

@pieh pieh commented Jan 5, 2024

Summary

Reverts #724 + adds fixes needed:

ntl dev clears .netlify/functions-internal so we have to (re)generate them. Alternatively we could skip that and rely on gatsby dev server handling functions however this moves ntl dev further away from builds (+ there is some quirk with with CLI where */x-www-form-urlencoded and multipart/form-data requests are not proxied to dev server at least currently).

This also clears out redirects produced by gatsby-plugin-netlify AND gatsby-adapter-netlify if builld happened before - those redirects would be for DSG/SSR functions that can't work in dev, because gatsby doesn't even produce engines in dev and DSG/SSR pages are handled just the same as SSG pages in dev

Test plan

  1. Visit the Deploy Preview (insert link to specific page) ...

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

FRA-181

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.

Copy link

netlify bot commented Jan 5, 2024

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

Name Link
🔨 Latest commit 84d868e
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-gatsby-demo-v5/deploys/6597fb695fce780008a5b14e
😎 Deploy Preview https://deploy-preview-738--netlify-plugin-gatsby-demo-v5.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 configuration.

Copy link

netlify bot commented Jan 5, 2024

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

Name Link
🔨 Latest commit 84d868e
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-gatsby-demo/deploys/6597fb6939bf980008b0431f
😎 Deploy Preview https://deploy-preview-738--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 configuration.

@pieh pieh changed the title chore: unpin netlify-cli used for tests fix: clear redirects/rewrites produced by previous builds in ntl dev Jan 5, 2024
constants,
}: NetlifyPluginOptions): Promise<void> {
// eslint-disable-next-line no-param-reassign
netlifyConfig.build.environment.GATSBY_PRECOMPILE_DEVELOP_FUNCTIONS = `true`
Copy link
Contributor Author

@pieh pieh Jan 5, 2024

Choose a reason for hiding this comment

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

Gatsby compiles functions lazily in dev (waiting for /api/X to be requested before function is compiled) by default which cause problems if we want to wrap them - this will force compile them eagerly

Comment on lines +217 to +219
contents: neededFunctions.includes('API')
? '/api/* /.netlify/functions/__api 200'
: '',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this now always handles redirects - if API is "not needed" - it will clean up dangling redirect

@pieh pieh marked this pull request as ready for review January 5, 2024 13:19
@pieh pieh requested a review from a team as a code owner January 5, 2024 13:19
@pieh pieh changed the title fix: clear redirects/rewrites produced by previous builds in ntl dev fix: clear redirects/rewrites produced by previous builds and generate functions in ntl dev Jan 5, 2024
@pieh pieh merged commit e66731c into main Jan 10, 2024
29 checks passed
@pieh pieh deleted the fix/unpin-cli branch January 10, 2024 07:22
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.

None yet

2 participants