Unverified Commit 241195dd authored by Steven's avatar Steven Committed by GitHub

BREAKING CHANGE: Rename `next/image` to `next/legacy/image` & rename…

BREAKING CHANGE: Rename `next/image` to `next/legacy/image` & rename `next/future/image` to `next/image` (#41399)

This PR introduces breaking changes by renaming components.

- Rename `next/image` to `next/legacy/image`
- Rename `next/future/image` to `next/image`

The diff is very confusing because both components are very similar so git got confused.
parent 560e93ef
......@@ -1067,7 +1067,7 @@ export default async function getBaseWebpackConfig(
}
const notExternalModules =
/^(?:private-next-pages\/|next\/(?:dist\/pages\/|(?:app|document|link|image|future\/image|constants|dynamic|script|navigation|headers)$)|string-hash|private-next-rsc-mod-ref-proxy$)/
/^(?:private-next-pages\/|next\/(?:dist\/pages\/|(?:app|document|link|image|legacy\/image|constants|dynamic|script|navigation|headers)$)|string-hash|private-next-rsc-mod-ref-proxy$)/
if (notExternalModules.test(request)) {
return
}
......
......@@ -21,6 +21,7 @@ export type SWC_TARGET_TRIPLE =
export type Feature =
| 'next/image'
| 'next/future/image'
| 'next/legacy/image'
| 'next/script'
| 'next/dynamic'
| 'swcLoader'
......@@ -58,6 +59,7 @@ interface Connection {
const FEATURE_MODULE_MAP: ReadonlyMap<Feature, string> = new Map([
['next/image', '/next/image.js'],
['next/future/image', '/next/future/image.js'],
['next/legacy/image', '/next/legacy/image.js'],
['next/script', '/next/script.js'],
['next/dynamic', '/next/dynamic.js'],
])
......
This diff is collapsed.
import Image from '../dist/client/future/image'
export * from '../dist/client/future/image'
export default Image
module.exports = require('../dist/client/future/image')
import Image from '../dist/client/legacy/image'
export * from '../dist/client/legacy/image'
export default Image
module.exports = require('../dist/client/legacy/image')
......@@ -27,6 +27,7 @@
"error.js",
"error.d.ts",
"future",
"legacy",
"script.js",
"script.d.ts",
"server.js",
......
......@@ -132,6 +132,7 @@ export type EventBuildFeatureUsage = {
// *before* you make changes here.
featureName:
| 'next/image'
| 'next/legacy/image'
| 'next/future/image'
| 'next/script'
| 'next/dynamic'
......
......@@ -14,6 +14,7 @@
"./*.d.ts",
"future/*.d.ts",
"image-types/global.d.ts",
"legacy/*.d.ts",
"types/compiled.d.ts"
]
}
......@@ -236,13 +236,20 @@ describe('app dir - rsc basics', () => {
expect(html).toContain('This page could not be found')
})
it('should suspense next/image in server components', async () => {
const imageHTML = await renderViaHTTP(next.url, '/next-api/image')
it('should suspense next/legacy/image in server components', async () => {
const imageHTML = await renderViaHTTP(next.url, '/next-api/image-legacy')
const imageTag = getNodeBySelector(imageHTML, '#myimg')
expect(imageTag.attr('src')).toContain('data:image')
})
it('should suspense next/image in server components', async () => {
const imageHTML = await renderViaHTTP(next.url, '/next-api/image-new')
const imageTag = getNodeBySelector(imageHTML, '#myimg')
expect(imageTag.attr('src')).toMatch(/test.+jpg/)
})
it('should handle various kinds of exports correctly', async () => {
const html = await renderViaHTTP(next.url, '/various-exports')
const content = getNodeBySelector(html, 'body').text()
......
import NextImage from 'next/legacy/image'
import src from '../../../public/test.jpg'
// Keep arrow function to test rsc loaders
const Page = () => {
return <NextImage id="myimg" src={src} />
}
export default Page
......@@ -8,7 +8,6 @@ import {
launchApp,
nextBuild,
nextStart,
renderViaHTTP,
waitFor,
} from 'next-test-utils'
import { join } from 'path'
......@@ -225,33 +224,6 @@ describe('Image Optimizer', () => {
)
})
it('should error when loader=custom but loader prop is undefined', async () => {
await nextConfig.replace(
'{ /* replaceme */ }',
JSON.stringify({
images: {
loader: 'custom',
},
})
)
let output = ''
const appPort = await findPort()
app = await launchApp(appDir, appPort, {
onStderr(msg) {
output += msg || ''
},
onStdout(msg) {
output += msg || ''
},
})
await renderViaHTTP(appPort, '/', {})
await killApp(app).catch(() => {})
await nextConfig.restore()
expect(output).toMatch(
/Error: Image with src "(.+)" is missing "loader" prop/
)
})
it('should error when images.formats contains invalid values', async () => {
await nextConfig.replace(
'{ /* replaceme */ }',
......
import React from 'react'
import Image from 'next/future/image'
import Image from 'next/legacy/image'
import img from '../public/test.jpg'
const Page = () => {
......
import React from 'react'
import Image from 'next/future/image'
import Image from 'next/legacy/image'
import testTall from './tall.png'
......
import React from 'react'
import Image from 'next/future/image'
import Image from 'next/legacy/image'
const Page = () => {
return (
......
import Image from 'next/future/image'
import Image from 'next/legacy/image'
import React from 'react'
const Page = () => {
......
import React from 'react'
import Image from 'next/future/image'
import Image from 'next/legacy/image'
const Page = () => {
return (
......
import React from 'react'
import Image from 'next/future/image'
import Image from 'next/legacy/image'
const Page = () => {
return (
......
import React from 'react'
import Image from 'next/future/image'
import Image from 'next/legacy/image'
const Page = () => {
return (
......
import React from 'react'
import Image from 'next/image'
import Image from 'next/legacy/image'
const Page = () => {
return (
......
import React from 'react'
import Image from 'next/image'
import Image from 'next/legacy/image'
const Page = () => {
return (
......
import React from 'react'
import Image from 'next/image'
import Image from 'next/legacy/image'
const Page = () => {
return (
......
import React from 'react'
import Image from 'next/image'
import Image from 'next/legacy/image'
const Page = () => {
return (
......
import React from 'react'
import Image from 'next/future/image'
import Image from 'next/legacy/image'
const Page = () => {
return (
......
import Image from 'next/future/image'
import Image from 'next/legacy/image'
import React from 'react'
import * as styles from './prose.module.css'
......
import Image from 'next/image'
import Image from 'next/legacy/image'
import React from 'react'
const Page = () => {
......
import React from 'react'
import Image from 'next/future/image'
import Image from 'next/legacy/image'
const Page = () => {
return (
......
import React from 'react'
import testImg from '../public/foo/test-rect.jpg'
import Image from 'next/image'
import Image from 'next/legacy/image'
import testJPG from '../public/test.jpg'
import testPNG from '../public/test.png'
......
import React, { useState } from 'react'
import Image from 'next/future/image'
import Image from 'next/legacy/image'
const Page = () => {
const [toggled, setToggled] = useState(false)
......
import React from 'react'
import Image from 'next/image'
import Image from 'next/legacy/image'
import Link from 'next/link'
const ClientSide = () => {
......
import React from 'react'
import Image from 'next/image'
import Image from 'next/legacy/image'
const Errors = () => {
return (
......
import React from 'react'
import Image from 'next/image'
import Image from 'next/legacy/image'
import Link from 'next/link'
import Head from 'next/head'
......
import React from 'react'
import Image from 'next/image'
import Image from 'next/legacy/image'
const Lazy = () => {
return (
......
import Image from 'next/image'
import Image from 'next/legacy/image'
const LoaderExample = () => {
return (
......
import React from 'react'
import Image from 'next/image'
import Image from 'next/legacy/image'
const myLoader = ({ src, width, quality }) => {
return `https://customresolver.com/${src}?w~~${width},q~~${quality}`
......
import React from 'react'
import Image from 'next/image'
import Image from 'next/legacy/image'
import Link from 'next/link'
const myLoader = ({ src, width, quality }) => {
......
import React from 'react'
import Image from 'next/future/image'
import Image from 'next/legacy/image'
import testTall from './tall.png'
......
import React, { useEffect, useState } from 'react'
import Image from 'next/future/image'
import Image from 'next/legacy/image'
const Page = () => {
const [src, setSrc] = useState()
......
import React from 'react'
import Image from 'next/image'
import Image from 'next/legacy/image'
export default function Page() {
return (
......
import React from 'react'
import Image from 'next/image'
import Image from 'next/legacy/image'
const Page = () => {
return (
......
import React from 'react'
import Image from 'next/future/image'
import Image from 'next/legacy/image'
const Page = () => {
return (
......
import Image from 'next/future/image'
import Image from 'next/legacy/image'
import React from 'react'
const Page = () => {
......
import React from 'react'
import Image from 'next/future/image'
import Image from 'next/legacy/image'
const Page = () => {
return (
......
import React from 'react'
import Image from 'next/future/image'
import Image from 'next/legacy/image'
import img from '../public/test.jpg'
const Page = () => {
......
import React from 'react'
import Image from 'next/future/image'
import Image from 'next/legacy/image'
const Page = () => {
return (
......
import React from 'react'
import Image from 'next/future/image'
import Image from 'next/legacy/image'
import testBMP from '../public/test.bmp'
const Page = () => {
......
import React from 'react'
import Image from 'next/future/image'
import Image from 'next/legacy/image'
const Page = () => {
return (
......
import React from 'react'
import Image from 'next/image'
import Image from 'next/legacy/image'
const Page = () => {
return (
......
import React from 'react'
import Image from 'next/future/image'
import Image from 'next/legacy/image'
const Page = () => {
return (
......
import React from 'react'
import Image from 'next/future/image'
import Image from 'next/legacy/image'
const Page = () => {
return (
......
import React from 'react'
import Image from 'next/image'
import Image from 'next/legacy/image'
const Page = () => {
return (
......
import React from 'react'
import Image from 'next/image'
import Image from 'next/legacy/image'
export default function Page() {
return (
......
import React from 'react'
import Image from 'next/image'
import Image from 'next/legacy/image'
import jpg from '../public/test.jpg'
import png from '../public/test.png'
import avif from '../public/test.avif'
......
import React from 'react'
import Image from 'next/image'
import Image from 'next/legacy/image'
const Page = () => {
return (
......
import React from 'react'
import Image from 'next/image'
import Image from 'next/legacy/image'
const Page = () => {
return (
......
import React from 'react'
import Image from 'next/image'
import Image from 'next/legacy/image'
const Page = () => {
return (
......
import React from 'react'
import Image from 'next/image'
import Image from 'next/legacy/image'
import img from '../public/test.jpg'
import style from '../style.module.css'
......
import React from 'react'
import Image from 'next/image'
import Image from 'next/legacy/image'
const Page = () => {
return (
......
import React from 'react'
import Image from 'next/image'
import Image from 'next/legacy/image'
const Page = () => {
const [src, setSrc] = React.useState('/test.jpg')
......
import React, { useRef } from 'react'
import Image from 'next/image'
import Image from 'next/legacy/image'
const Page = () => {
const myRef = useRef(null)
......
import React from 'react'
import Image from 'next/future/image'
import Image from 'next/legacy/image'
const Page = () => {
return (
......
import React from 'react'
import Image from 'next/future/image'
import Image from 'next/legacy/image'
const Page = () => {
return (
......
import { useState } from 'react'
import Image from 'next/image'
import Image from 'next/legacy/image'
const Page = () => {
return (
......
import { useState } from 'react'
import Image from 'next/image'
import Image from 'next/legacy/image'
const Page = () => {
// Hoisted state to count each image load callback
......
import { useState } from 'react'
import Image from 'next/image'
import Image from 'next/legacy/image'
const Page = () => {
// Hoisted state to count each image load callback
......
import React from 'react'
import Image from 'next/image'
import Image from 'next/legacy/image'
const Page = () => {
return (
......
import React from 'react'
import Image from 'next/image'
import Image from 'next/legacy/image'
const Page = () => {
return (
......
import Image from 'next/future/image'
import Image from 'next/legacy/image'
import React from 'react'
import * as styles from './prose.module.css'
......
import Image from 'next/image'
import Image from 'next/legacy/image'
import React from 'react'
const Page = () => {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment