-
Notifications
You must be signed in to change notification settings - Fork 27.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(next/image): import error
preload
is not exported from `react-d…
…om` (#54688) - Fixes #54416 - Related to #47659 Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
- Loading branch information
Showing
5 changed files
with
66 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
test/integration/next-image-new/loader-config-edge-runtime/pages/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import Image from 'next/image' | ||
|
||
export async function middleware(request) { | ||
// reference Image so it's not tree shaken / DCE | ||
console.log(`Has image: ${Boolean(Image)}`) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import Image from 'next/image' | ||
|
||
export default function Page() { | ||
return ( | ||
<> | ||
<h1>Its Works</h1> | ||
<Image | ||
alt="empty" | ||
src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" | ||
width={400} | ||
height={400} | ||
/> | ||
</> | ||
) | ||
} |
40 changes: 40 additions & 0 deletions
40
test/integration/next-image-new/middleware/test/index.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* eslint-env jest */ | ||
|
||
import { join } from 'path' | ||
import { check, findPort, killApp, launchApp } from 'next-test-utils' | ||
import webdriver from 'next-webdriver' | ||
|
||
const appDir = join(__dirname, '../') | ||
let appPort: number | ||
let app: Awaited<ReturnType<typeof launchApp>> | ||
let output = '' | ||
|
||
describe('Image with middleware in edge func', () => { | ||
describe('dev mode', () => { | ||
beforeAll(async () => { | ||
appPort = await findPort() | ||
app = await launchApp(appDir, appPort, { | ||
onStdout: (s) => { | ||
output += s | ||
}, | ||
onStderr: (s) => { | ||
output += s | ||
}, | ||
}) | ||
}) | ||
afterAll(async () => { | ||
await killApp(app) | ||
}) | ||
|
||
it('should not error', async () => { | ||
/** | ||
- wait compiling /middleware (client and server)... | ||
- warn ../../../../packages/next/dist/esm/client/image-component.js | ||
Attempted import error: 'preload' is not exported from 'react-dom' (imported as 'preload'). | ||
*/ | ||
await webdriver(appPort, '/') | ||
await check(() => output, /compiled client and server successfully/) | ||
expect(output).not.toContain(`'preload' is not exported from 'react-dom'`) | ||
}) | ||
}) | ||
}) |