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( ...@@ -1067,7 +1067,7 @@ export default async function getBaseWebpackConfig(
} }
const notExternalModules = 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)) { if (notExternalModules.test(request)) {
return return
} }
......
...@@ -21,6 +21,7 @@ export type SWC_TARGET_TRIPLE = ...@@ -21,6 +21,7 @@ export type SWC_TARGET_TRIPLE =
export type Feature = export type Feature =
| 'next/image' | 'next/image'
| 'next/future/image' | 'next/future/image'
| 'next/legacy/image'
| 'next/script' | 'next/script'
| 'next/dynamic' | 'next/dynamic'
| 'swcLoader' | 'swcLoader'
...@@ -58,6 +59,7 @@ interface Connection { ...@@ -58,6 +59,7 @@ interface Connection {
const FEATURE_MODULE_MAP: ReadonlyMap<Feature, string> = new Map([ const FEATURE_MODULE_MAP: ReadonlyMap<Feature, string> = new Map([
['next/image', '/next/image.js'], ['next/image', '/next/image.js'],
['next/future/image', '/next/future/image.js'], ['next/future/image', '/next/future/image.js'],
['next/legacy/image', '/next/legacy/image.js'],
['next/script', '/next/script.js'], ['next/script', '/next/script.js'],
['next/dynamic', '/next/dynamic.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 @@ ...@@ -27,6 +27,7 @@
"error.js", "error.js",
"error.d.ts", "error.d.ts",
"future", "future",
"legacy",
"script.js", "script.js",
"script.d.ts", "script.d.ts",
"server.js", "server.js",
......
...@@ -132,6 +132,7 @@ export type EventBuildFeatureUsage = { ...@@ -132,6 +132,7 @@ export type EventBuildFeatureUsage = {
// *before* you make changes here. // *before* you make changes here.
featureName: featureName:
| 'next/image' | 'next/image'
| 'next/legacy/image'
| 'next/future/image' | 'next/future/image'
| 'next/script' | 'next/script'
| 'next/dynamic' | 'next/dynamic'
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
"./*.d.ts", "./*.d.ts",
"future/*.d.ts", "future/*.d.ts",
"image-types/global.d.ts", "image-types/global.d.ts",
"legacy/*.d.ts",
"types/compiled.d.ts" "types/compiled.d.ts"
] ]
} }
...@@ -236,13 +236,20 @@ describe('app dir - rsc basics', () => { ...@@ -236,13 +236,20 @@ describe('app dir - rsc basics', () => {
expect(html).toContain('This page could not be found') expect(html).toContain('This page could not be found')
}) })
it('should suspense next/image in server components', async () => { it('should suspense next/legacy/image in server components', async () => {
const imageHTML = await renderViaHTTP(next.url, '/next-api/image') const imageHTML = await renderViaHTTP(next.url, '/next-api/image-legacy')
const imageTag = getNodeBySelector(imageHTML, '#myimg') const imageTag = getNodeBySelector(imageHTML, '#myimg')
expect(imageTag.attr('src')).toContain('data:image') 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 () => { it('should handle various kinds of exports correctly', async () => {
const html = await renderViaHTTP(next.url, '/various-exports') const html = await renderViaHTTP(next.url, '/various-exports')
const content = getNodeBySelector(html, 'body').text() 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 { ...@@ -8,7 +8,6 @@ import {
launchApp, launchApp,
nextBuild, nextBuild,
nextStart, nextStart,
renderViaHTTP,
waitFor, waitFor,
} from 'next-test-utils' } from 'next-test-utils'
import { join } from 'path' import { join } from 'path'
...@@ -225,33 +224,6 @@ describe('Image Optimizer', () => { ...@@ -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 () => { it('should error when images.formats contains invalid values', async () => {
await nextConfig.replace( await nextConfig.replace(
'{ /* replaceme */ }', '{ /* replaceme */ }',
......
import React from 'react' import React from 'react'
import Image from 'next/future/image' import Image from 'next/legacy/image'
import img from '../public/test.jpg' import img from '../public/test.jpg'
const Page = () => { const Page = () => {
......
import React from 'react' import React from 'react'
import Image from 'next/future/image' import Image from 'next/legacy/image'
import testTall from './tall.png' import testTall from './tall.png'
......
import React from 'react' import React from 'react'
import Image from 'next/future/image' import Image from 'next/legacy/image'
const Page = () => { const Page = () => {
return ( return (
......
import Image from 'next/future/image' import Image from 'next/legacy/image'
import React from 'react' import React from 'react'
const Page = () => { const Page = () => {
......
import React from 'react' import React from 'react'
import Image from 'next/future/image' import Image from 'next/legacy/image'
const Page = () => { const Page = () => {
return ( return (
......
import React from 'react' import React from 'react'
import Image from 'next/future/image' import Image from 'next/legacy/image'
const Page = () => { const Page = () => {
return ( return (
......
import React from 'react' import React from 'react'
import Image from 'next/future/image' import Image from 'next/legacy/image'
const Page = () => { const Page = () => {
return ( return (
......
import React from 'react' import React from 'react'
import Image from 'next/image' import Image from 'next/legacy/image'
const Page = () => { const Page = () => {
return ( return (
......
import React from 'react' import React from 'react'
import Image from 'next/image' import Image from 'next/legacy/image'
const Page = () => { const Page = () => {
return ( return (
......
import React from 'react' import React from 'react'
import Image from 'next/image' import Image from 'next/legacy/image'
const Page = () => { const Page = () => {
return ( return (
......
import React from 'react' import React from 'react'
import Image from 'next/image' import Image from 'next/legacy/image'
const Page = () => { const Page = () => {
return ( return (
......
import React from 'react' import React from 'react'
import Image from 'next/future/image' import Image from 'next/legacy/image'
const Page = () => { const Page = () => {
return ( return (
......
import Image from 'next/future/image' import Image from 'next/legacy/image'
import React from 'react' import React from 'react'
import * as styles from './prose.module.css' import * as styles from './prose.module.css'
......
import Image from 'next/image' import Image from 'next/legacy/image'
import React from 'react' import React from 'react'
const Page = () => { const Page = () => {
......
import React from 'react' import React from 'react'
import Image from 'next/future/image' import Image from 'next/legacy/image'
const Page = () => { const Page = () => {
return ( return (
......
import React from 'react' import React from 'react'
import testImg from '../public/foo/test-rect.jpg' 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 testJPG from '../public/test.jpg'
import testPNG from '../public/test.png' import testPNG from '../public/test.png'
......
import React, { useState } from 'react' import React, { useState } from 'react'
import Image from 'next/future/image' import Image from 'next/legacy/image'
const Page = () => { const Page = () => {
const [toggled, setToggled] = useState(false) const [toggled, setToggled] = useState(false)
......
import React from 'react' import React from 'react'
import Image from 'next/image' import Image from 'next/legacy/image'
import Link from 'next/link' import Link from 'next/link'
const ClientSide = () => { const ClientSide = () => {
......
import React from 'react' import React from 'react'
import Image from 'next/image' import Image from 'next/legacy/image'
const Errors = () => { const Errors = () => {
return ( return (
......
import React from 'react' import React from 'react'
import Image from 'next/image' import Image from 'next/legacy/image'
import Link from 'next/link' import Link from 'next/link'
import Head from 'next/head' import Head from 'next/head'
......
import React from 'react' import React from 'react'
import Image from 'next/image' import Image from 'next/legacy/image'
const Lazy = () => { const Lazy = () => {
return ( return (
......
import Image from 'next/image' import Image from 'next/legacy/image'
const LoaderExample = () => { const LoaderExample = () => {
return ( return (
......
import React from 'react' import React from 'react'
import Image from 'next/image' import Image from 'next/legacy/image'
const myLoader = ({ src, width, quality }) => { const myLoader = ({ src, width, quality }) => {
return `https://customresolver.com/${src}?w~~${width},q~~${quality}` return `https://customresolver.com/${src}?w~~${width},q~~${quality}`
......
import React from 'react' import React from 'react'
import Image from 'next/image' import Image from 'next/legacy/image'
import Link from 'next/link' import Link from 'next/link'
const myLoader = ({ src, width, quality }) => { const myLoader = ({ src, width, quality }) => {
......
import React from 'react' import React from 'react'
import Image from 'next/future/image' import Image from 'next/legacy/image'
import testTall from './tall.png' import testTall from './tall.png'
......
import React, { useEffect, useState } from 'react' import React, { useEffect, useState } from 'react'
import Image from 'next/future/image' import Image from 'next/legacy/image'
const Page = () => { const Page = () => {
const [src, setSrc] = useState() const [src, setSrc] = useState()
......
import React from 'react' import React from 'react'
import Image from 'next/image' import Image from 'next/legacy/image'
export default function Page() { export default function Page() {
return ( return (
......
import React from 'react' import React from 'react'
import Image from 'next/image' import Image from 'next/legacy/image'
const Page = () => { const Page = () => {
return ( return (
......
import React from 'react' import React from 'react'
import Image from 'next/future/image' import Image from 'next/legacy/image'
const Page = () => { const Page = () => {
return ( return (
......
import Image from 'next/future/image' import Image from 'next/legacy/image'
import React from 'react' import React from 'react'
const Page = () => { const Page = () => {
......
import React from 'react' import React from 'react'
import Image from 'next/future/image' import Image from 'next/legacy/image'
const Page = () => { const Page = () => {
return ( return (
......
import React from 'react' import React from 'react'
import Image from 'next/future/image' import Image from 'next/legacy/image'
import img from '../public/test.jpg' import img from '../public/test.jpg'
const Page = () => { const Page = () => {
......
import React from 'react' import React from 'react'
import Image from 'next/future/image' import Image from 'next/legacy/image'
const Page = () => { const Page = () => {
return ( return (
......
import React from 'react' import React from 'react'
import Image from 'next/future/image' import Image from 'next/legacy/image'
import testBMP from '../public/test.bmp' import testBMP from '../public/test.bmp'
const Page = () => { const Page = () => {
......
import React from 'react' import React from 'react'
import Image from 'next/future/image' import Image from 'next/legacy/image'
const Page = () => { const Page = () => {
return ( return (
......
import React from 'react' import React from 'react'
import Image from 'next/image' import Image from 'next/legacy/image'
const Page = () => { const Page = () => {
return ( return (
......
import React from 'react' import React from 'react'
import Image from 'next/future/image' import Image from 'next/legacy/image'
const Page = () => { const Page = () => {
return ( return (
......
import React from 'react' import React from 'react'
import Image from 'next/future/image' import Image from 'next/legacy/image'
const Page = () => { const Page = () => {
return ( return (
......
import React from 'react' import React from 'react'
import Image from 'next/image' import Image from 'next/legacy/image'
const Page = () => { const Page = () => {
return ( return (
......
import React from 'react' import React from 'react'
import Image from 'next/image' import Image from 'next/legacy/image'
export default function Page() { export default function Page() {
return ( return (
......
import React from 'react' import React from 'react'
import Image from 'next/image' import Image from 'next/legacy/image'
import jpg from '../public/test.jpg' import jpg from '../public/test.jpg'
import png from '../public/test.png' import png from '../public/test.png'
import avif from '../public/test.avif' import avif from '../public/test.avif'
......
import React from 'react' import React from 'react'
import Image from 'next/image' import Image from 'next/legacy/image'
const Page = () => { const Page = () => {
return ( return (
......
import React from 'react' import React from 'react'
import Image from 'next/image' import Image from 'next/legacy/image'
const Page = () => { const Page = () => {
return ( return (
......
import React from 'react' import React from 'react'
import Image from 'next/image' import Image from 'next/legacy/image'
const Page = () => { const Page = () => {
return ( return (
......
import React from 'react' import React from 'react'
import Image from 'next/image' import Image from 'next/legacy/image'
import img from '../public/test.jpg' import img from '../public/test.jpg'
import style from '../style.module.css' import style from '../style.module.css'
......
import React from 'react' import React from 'react'
import Image from 'next/image' import Image from 'next/legacy/image'
const Page = () => { const Page = () => {
return ( return (
......
import React from 'react' import React from 'react'
import Image from 'next/image' import Image from 'next/legacy/image'
const Page = () => { const Page = () => {
const [src, setSrc] = React.useState('/test.jpg') const [src, setSrc] = React.useState('/test.jpg')
......
import React, { useRef } from 'react' import React, { useRef } from 'react'
import Image from 'next/image' import Image from 'next/legacy/image'
const Page = () => { const Page = () => {
const myRef = useRef(null) const myRef = useRef(null)
......
import React from 'react' import React from 'react'
import Image from 'next/future/image' import Image from 'next/legacy/image'
const Page = () => { const Page = () => {
return ( return (
......
import React from 'react' import React from 'react'
import Image from 'next/future/image' import Image from 'next/legacy/image'
const Page = () => { const Page = () => {
return ( return (
......
import { useState } from 'react' import { useState } from 'react'
import Image from 'next/image' import Image from 'next/legacy/image'
const Page = () => { const Page = () => {
return ( return (
......
import { useState } from 'react' import { useState } from 'react'
import Image from 'next/image' import Image from 'next/legacy/image'
const Page = () => { const Page = () => {
// Hoisted state to count each image load callback // Hoisted state to count each image load callback
......
import { useState } from 'react' import { useState } from 'react'
import Image from 'next/image' import Image from 'next/legacy/image'
const Page = () => { const Page = () => {
// Hoisted state to count each image load callback // Hoisted state to count each image load callback
......
import React from 'react' import React from 'react'
import Image from 'next/image' import Image from 'next/legacy/image'
const Page = () => { const Page = () => {
return ( return (
......
import React from 'react' import React from 'react'
import Image from 'next/image' import Image from 'next/legacy/image'
const Page = () => { const Page = () => {
return ( return (
......
import Image from 'next/future/image' import Image from 'next/legacy/image'
import React from 'react' import React from 'react'
import * as styles from './prose.module.css' import * as styles from './prose.module.css'
......
import Image from 'next/image' import Image from 'next/legacy/image'
import React from 'react' import React from 'react'
const Page = () => { 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