-
Notifications
You must be signed in to change notification settings - Fork 27.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: babel usage with next/image (#61835)
### Why The `process/browser` lib was imported and being transformed, but `process.browser = true` turns to `true = true` that causes the compilation error, we need to exclude them from certain compilation layers ### What - Fixes #61116 Closes NEXT-2410 Closes NEXT-2328 --------- Co-authored-by: Jiachi Liu <inbox@huozhi.im>
- Loading branch information
Showing
8 changed files
with
72 additions
and
11 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
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
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,4 @@ | ||
{ | ||
"presets": ["next/babel"], | ||
"plugins": [] | ||
} |
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,12 @@ | ||
export const metadata = { | ||
title: 'Next.js', | ||
description: 'Generated by Next.js', | ||
} | ||
|
||
export default function RootLayout({ children }) { | ||
return ( | ||
<html lang="en"> | ||
<body>{children}</body> | ||
</html> | ||
) | ||
} |
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,12 @@ | ||
import Image from 'next/image' | ||
|
||
export default function Home() { | ||
return ( | ||
<Image | ||
alt="red square" | ||
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8DwHwAFBQIAX8jx0gAAAABJRU5ErkJggg==" | ||
width={64} | ||
height={64} | ||
/> | ||
) | ||
} |
19 changes: 19 additions & 0 deletions
19
test/integration/babel-next-image/babel-next-image.test.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* eslint-env jest */ | ||
|
||
import { fetchViaHTTP, findPort, killApp, launchApp } from 'next-test-utils' | ||
;(process.env.TURBOPACK ? describe.skip : describe)('babel-next-image', () => { | ||
let appPort | ||
let app | ||
|
||
beforeAll(async () => { | ||
appPort = await findPort() | ||
app = await launchApp(__dirname, appPort) | ||
}) | ||
|
||
afterAll(() => killApp(app)) | ||
|
||
it('should work with babel and next/image', async () => { | ||
const res = await fetchViaHTTP(appPort, '/') | ||
expect(res.status).toBe(200) | ||
}) | ||
}) |