Unverified Commit 1180a6ec authored by Joshua Hannaford's avatar Joshua Hannaford Committed by GitHub

fix(Turbopack): Address duplicated metadata image modules when they are impored (#82367)

parent ff4f10a5
...@@ -35,9 +35,16 @@ pub struct StructuredImageFileSource { ...@@ -35,9 +35,16 @@ pub struct StructuredImageFileSource {
impl Source for StructuredImageFileSource { impl Source for StructuredImageFileSource {
#[turbo_tasks::function] #[turbo_tasks::function]
fn ident(&self) -> Vc<AssetIdent> { fn ident(&self) -> Vc<AssetIdent> {
let modifier = match self.blur_placeholder_mode {
BlurPlaceholderMode::DataUrl => rcstr!("structured image object with data url"),
BlurPlaceholderMode::NextImageUrl => {
rcstr!("structured image object with next image url")
}
BlurPlaceholderMode::None => rcstr!("structured image object"),
};
self.image self.image
.ident() .ident()
.with_modifier(rcstr!("structured image object")) .with_modifier(modifier)
.rename_as(rcstr!("*.mjs")) .rename_as(rcstr!("*.mjs"))
} }
} }
......
export default function Layout({ children }) {
return (
<html>
<head></head>
<body>{children}</body>
</html>
)
}
import _img from './apple-icon.png'
import _img2 from './icon.png'
import _img3 from './opengraph-image.png'
import _img4 from './twitter-image.png'
import _img5 from './not-metadata-image.png'
import Image from 'next/image'
export default function Page() {
return (
<>
<Image src={_img} placeholder="blur" />
<Image src={_img2} placeholder="blur" />
<Image src={_img3} placeholder="blur" />
<Image src={_img4} placeholder="blur" />
<Image src={_img5} placeholder="blur" />
</>
)
}
import { nextTestSetup } from 'e2e-utils'
describe('app dir - metadata image files', () => {
const { next } = nextTestSetup({
files: __dirname,
})
it('should handle imported metadata images', async () => {
const browser = await next.browser('/')
const images = await browser.elementsByCss('img')
expect(images.length).toBe(5)
for (const image of images) {
const src = await image.getAttribute('src')
expect(src).not.toContain('undefined')
}
})
})
...@@ -3093,6 +3093,15 @@ ...@@ -3093,6 +3093,15 @@
"flakey": [], "flakey": [],
"runtimeError": false "runtimeError": false
}, },
"test/e2e/app-dir/metadata-image-files/metadata-image-files.test.ts": {
"passed": [
"app dir - metadata image files should handle imported metadata images"
],
"failed": [],
"pending": [],
"flakey": [],
"runtimeError": false
},
"test/e2e/app-dir/metadata-json-manifest/index.test.ts": { "test/e2e/app-dir/metadata-json-manifest/index.test.ts": {
"passed": [ "passed": [
"app-dir metadata-json-manifest should support metadata.json manifest" "app-dir metadata-json-manifest should support metadata.json manifest"
...@@ -6942,6 +6942,15 @@ ...@@ -6942,6 +6942,15 @@
"flakey": [], "flakey": [],
"runtimeError": false "runtimeError": false
}, },
"test/e2e/app-dir/metadata-image-files/metadata-image-files.test.ts": {
"passed": [
"app dir - metadata image files should handle imported metadata images"
],
"failed": [],
"pending": [],
"flakey": [],
"runtimeError": false
},
"test/e2e/app-dir/metadata-json-manifest/index.test.ts": { "test/e2e/app-dir/metadata-json-manifest/index.test.ts": {
"passed": [ "passed": [
"app-dir metadata-json-manifest should support metadata.json manifest" "app-dir metadata-json-manifest should support metadata.json manifest"
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