Skip to content

chore: replace next/legacy/image with next/image #1722

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

Merged
merged 10 commits into from
Oct 28, 2022
Merged

Conversation

nickytonline
Copy link

@nickytonline nickytonline commented Oct 26, 2022

Summary

Swaps next/legacy/image imports with next/image imports. I've also added a test to verify that a broken image due to image configuration in Next.js should error out if the host is not allowed.

Test plan

All the demo sites should build fine and all the tests should pass.

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

Closes #1721

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.

@netlify
Copy link

netlify bot commented Oct 26, 2022

Deploy Preview for netlify-plugin-nextjs-nx-monorepo-demo ready!

Name Link
🔨 Latest commit 9c2689c
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-nx-monorepo-demo/deploys/635c22ef84e710000832ab14
😎 Deploy Preview https://deploy-preview-1722--netlify-plugin-nextjs-nx-monorepo-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.

@netlify
Copy link

netlify bot commented Oct 26, 2022

Deploy Preview for netlify-plugin-nextjs-export-demo ready!

Name Link
🔨 Latest commit 9c2689c
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-export-demo/deploys/635c22efc32b0f000877b658
😎 Deploy Preview https://deploy-preview-1722--netlify-plugin-nextjs-export-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.

@netlify
Copy link

netlify bot commented Oct 26, 2022

Deploy Preview for netlify-plugin-nextjs-static-root-demo ready!

Name Link
🔨 Latest commit 9c2689c
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-static-root-demo/deploys/635c22eff55cae00085bc494
😎 Deploy Preview https://deploy-preview-1722--netlify-plugin-nextjs-static-root-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.

@netlify
Copy link

netlify bot commented Oct 26, 2022

Deploy Preview for next-plugin-edge-middleware ready!

Name Link
🔨 Latest commit 9c2689c
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-edge-middleware/deploys/635c22ef83f4200008993908
😎 Deploy Preview https://deploy-preview-1722--next-plugin-edge-middleware.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.

@github-actions github-actions bot added the type: chore work needed to keep the product and development running smoothly label Oct 26, 2022
@netlify
Copy link

netlify bot commented Oct 26, 2022

Deploy Preview for netlify-plugin-nextjs-next-auth-demo ready!

Name Link
🔨 Latest commit 9c2689c
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-next-auth-demo/deploys/635c22efc6311b0009fc5524
😎 Deploy Preview https://deploy-preview-1722--netlify-plugin-nextjs-next-auth-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.

@netlify
Copy link

netlify bot commented Oct 26, 2022

Deploy Preview for next-plugin-canary ready!

Name Link
🔨 Latest commit 9c2689c
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-canary/deploys/635c22efc18712000886413c
😎 Deploy Preview https://deploy-preview-1722--next-plugin-canary.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.

@netlify
Copy link

netlify bot commented Oct 26, 2022

Deploy Preview for next-i18next-demo ready!

Name Link
🔨 Latest commit 9c2689c
🔍 Latest deploy log https://app.netlify.com/sites/next-i18next-demo/deploys/635c22ef2dd4930008b75b30
😎 Deploy Preview https://deploy-preview-1722--next-i18next-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.

@netlify
Copy link

netlify bot commented Oct 26, 2022

Deploy Preview for nextjs-plugin-custom-routes-demo ready!

Name Link
🔨 Latest commit 9c2689c
🔍 Latest deploy log https://app.netlify.com/sites/nextjs-plugin-custom-routes-demo/deploys/635c22ef9d8df500080ef430
😎 Deploy Preview https://deploy-preview-1722--nextjs-plugin-custom-routes-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.

@netlify
Copy link

netlify bot commented Oct 26, 2022

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

Name Link
🔨 Latest commit 9c2689c
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-demo/deploys/635c22ef9974d5000806c11a
😎 Deploy Preview https://deploy-preview-1722--netlify-plugin-nextjs-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.

@nickytonline nickytonline changed the title chore: removed unused import wip Oct 26, 2022
@nickytonline nickytonline reopened this Oct 27, 2022
@nickytonline nickytonline changed the base branch from main to mk/canary-demo October 27, 2022 18:08
@nickytonline nickytonline changed the title wip Replace next/legacy/image with next/image Oct 27, 2022
@nickytonline nickytonline marked this pull request as ready for review October 27, 2022 18:21
@nickytonline nickytonline requested a review from a team October 27, 2022 18:21
@nickytonline nickytonline marked this pull request as draft October 27, 2022 18:22
@nickytonline nickytonline marked this pull request as ready for review October 27, 2022 19:03
'image has natural width'
).to.be.greaterThan(0)
})
cy.findByRole('img', { name: /tawny frogmouth/i })
Copy link
Author

Choose a reason for hiding this comment

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

prettier in action

@@ -71,7 +71,7 @@ module.exports = {
},
// https://nextjs.org/docs/basic-features/image-optimization#domains
images: {
domains: ['raw.githubusercontent.com', 'upload.wikimedia.org'],
Copy link
Author

Choose a reason for hiding this comment

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

Removed 'upload.wikimedia.org', as it was added a few weeks ago to prevent the /images page in the default demo from breaking due to Next.js throwing when the host is not supported for an image.

@ascorbic
Copy link
Contributor

Why is this based off the app dir branch?

@nickytonline
Copy link
Author

Why is this based off the app dir branch?

@ascorbic, I could've swarn these changes were related to the work in your branch, but pulling latest from main shows that is clearly not the case. Thursdays.

@nickytonline nickytonline changed the base branch from mk/canary-demo to main October 27, 2022 19:26
@nickytonline nickytonline changed the title Replace next/legacy/image with next/image fix : replace next/legacy/image with next/image Oct 27, 2022
@github-actions github-actions bot added the type: bug code to address defects in shipped code label Oct 27, 2022
@ascorbic
Copy link
Contributor

I think the confusion was because it's Next 13 stuff - but it was the other PR that we already merged.

@nickytonline nickytonline changed the title fix : replace next/legacy/image with next/image chore: replace next/legacy/image with next/image Oct 27, 2022
@nickytonline nickytonline self-assigned this Oct 27, 2022
@@ -615,7 +614,7 @@ describe('onBuild()', () => {
const imageConfigPath = path.join(constants.INTERNAL_FUNCTIONS_SRC, IMAGE_FUNCTION_NAME, 'imageconfig.json')
const imageConfigJson = await readJson(imageConfigPath)

expect(imageConfigJson.domains.length).toBe(2)
expect(imageConfigJson.domains.length).toBe(1)
Copy link
Author

Choose a reason for hiding this comment

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

).to.equal('0px')
it('should show throw if an image is not on the domains or remotePatterns allowlist', () => {
cy.request('/broken-image').then((response) => {
expect(response.status).to.eq(200)
Copy link
Author

Choose a reason for hiding this comment

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

The image is broken, but the page still loads with the error message which is why this is an HTTTP 200

@nickytonline nickytonline requested a review from a team October 27, 2022 19:56
@nickytonline nickytonline force-pushed the next-js-images branch 3 times, most recently from 0e2cb05 to dbd8558 Compare October 28, 2022 02:20
@nickytonline nickytonline force-pushed the next-js-images branch 2 times, most recently from 19be202 to b16d251 Compare October 28, 2022 14:26
@nickytonline
Copy link
Author

This was passing minus the preview spec flakiness, but I've rerun things and atm it's failing because things are timing out on waiting for sites to build. I'll let it rest for a bit and rerun later this afternoon.

@kodiakhq kodiakhq bot merged commit bcd7c11 into main Oct 28, 2022
@kodiakhq kodiakhq bot deleted the next-js-images branch October 28, 2022 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge type: bug code to address defects in shipped code type: chore work needed to keep the product and development running smoothly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issues with next/image in Next.js 13
3 participants