Skip to content

Commit 1180a6e

Browse files
authored
fix(Turbopack): Address duplicated metadata image modules when they are impored (#82367)
1 parent ff4f10a commit 1180a6e

File tree

11 files changed

+70
-1
lines changed

11 files changed

+70
-1
lines changed

crates/next-core/src/next_image/source_asset.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,16 @@ pub struct StructuredImageFileSource {
3535
impl Source for StructuredImageFileSource {
3636
#[turbo_tasks::function]
3737
fn ident(&self) -> Vc<AssetIdent> {
38+
let modifier = match self.blur_placeholder_mode {
39+
BlurPlaceholderMode::DataUrl => rcstr!("structured image object with data url"),
40+
BlurPlaceholderMode::NextImageUrl => {
41+
rcstr!("structured image object with next image url")
42+
}
43+
BlurPlaceholderMode::None => rcstr!("structured image object"),
44+
};
3845
self.image
3946
.ident()
40-
.with_modifier(rcstr!("structured image object"))
47+
.with_modifier(modifier)
4148
.rename_as(rcstr!("*.mjs"))
4249
}
4350
}
15.6 KB
Loading
6.54 KB
Loading
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default function Layout({ children }) {
2+
return (
3+
<html>
4+
<head></head>
5+
<body>{children}</body>
6+
</html>
7+
)
8+
}
6.54 KB
Loading
928 KB
Loading
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import _img from './apple-icon.png'
2+
import _img2 from './icon.png'
3+
import _img3 from './opengraph-image.png'
4+
import _img4 from './twitter-image.png'
5+
import _img5 from './not-metadata-image.png'
6+
import Image from 'next/image'
7+
8+
export default function Page() {
9+
return (
10+
<>
11+
<Image src={_img} placeholder="blur" />
12+
<Image src={_img2} placeholder="blur" />
13+
<Image src={_img3} placeholder="blur" />
14+
<Image src={_img4} placeholder="blur" />
15+
<Image src={_img5} placeholder="blur" />
16+
</>
17+
)
18+
}
6.54 KB
Loading
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { nextTestSetup } from 'e2e-utils'
2+
3+
describe('app dir - metadata image files', () => {
4+
const { next } = nextTestSetup({
5+
files: __dirname,
6+
})
7+
8+
it('should handle imported metadata images', async () => {
9+
const browser = await next.browser('/')
10+
const images = await browser.elementsByCss('img')
11+
expect(images.length).toBe(5)
12+
13+
for (const image of images) {
14+
const src = await image.getAttribute('src')
15+
expect(src).not.toContain('undefined')
16+
}
17+
})
18+
})

test/turbopack-build-tests-manifest.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3093,6 +3093,15 @@
30933093
"flakey": [],
30943094
"runtimeError": false
30953095
},
3096+
"test/e2e/app-dir/metadata-image-files/metadata-image-files.test.ts": {
3097+
"passed": [
3098+
"app dir - metadata image files should handle imported metadata images"
3099+
],
3100+
"failed": [],
3101+
"pending": [],
3102+
"flakey": [],
3103+
"runtimeError": false
3104+
},
30963105
"test/e2e/app-dir/metadata-json-manifest/index.test.ts": {
30973106
"passed": [
30983107
"app-dir metadata-json-manifest should support metadata.json manifest"

0 commit comments

Comments
 (0)