diff --git a/crates/next-api/src/app.rs b/crates/next-api/src/app.rs index dcf54e92ce25a..f59e0f38d2808 100644 --- a/crates/next-api/src/app.rs +++ b/crates/next-api/src/app.rs @@ -1134,8 +1134,8 @@ impl AppEndpoint { next_config: Vc, ) -> Result> { Ok(get_app_metadata_route_entry( - self.app_project.rsc_module_context(), - self.app_project.edge_rsc_module_context(), + self.app_project.route_module_context(), + self.app_project.edge_route_module_context(), self.app_project.project().project_path().owned().await?, self.page.clone(), *self.app_project.project().next_mode().await?, @@ -1194,11 +1194,7 @@ impl AppEndpoint { AppEndpointType::Metadata { metadata } => ( false, false, - if matches!(metadata, MetadataItem::Dynamic { .. }) { - EmitManifests::Full - } else { - EmitManifests::Minimal - }, + EmitManifests::Minimal, matches!(metadata, MetadataItem::Dynamic { .. }), ), }; diff --git a/test/e2e/app-dir/dynamic/app/api/route.js b/test/e2e/app-dir/dynamic/app/api/route.js new file mode 100644 index 0000000000000..9da3ca75999f9 --- /dev/null +++ b/test/e2e/app-dir/dynamic/app/api/route.js @@ -0,0 +1,5 @@ +import { DynamicComponent } from '../client-reference' + +export async function GET() { + return new Response('Hello ' + typeof DynamicComponent) +} diff --git a/test/e2e/app-dir/dynamic/app/client-reference.js b/test/e2e/app-dir/dynamic/app/client-reference.js new file mode 100644 index 0000000000000..f11004f7e106d --- /dev/null +++ b/test/e2e/app-dir/dynamic/app/client-reference.js @@ -0,0 +1,5 @@ +'use client' + +import dynamic from 'next/dynamic' + +export const DynamicComponent = dynamic(() => import('./dynamic-component')) diff --git a/test/e2e/app-dir/dynamic/app/dynamic-component.js b/test/e2e/app-dir/dynamic/app/dynamic-component.js new file mode 100644 index 0000000000000..f23de50e36b12 --- /dev/null +++ b/test/e2e/app-dir/dynamic/app/dynamic-component.js @@ -0,0 +1,7 @@ +const DynamicImportComponent = () => { + return ( +
This is a dynamically imported component
+ ) +} + +export default DynamicImportComponent diff --git a/test/e2e/app-dir/dynamic/app/sitemap.js b/test/e2e/app-dir/dynamic/app/sitemap.js new file mode 100644 index 0000000000000..d3fe8504436fb --- /dev/null +++ b/test/e2e/app-dir/dynamic/app/sitemap.js @@ -0,0 +1,14 @@ +import { DynamicComponent } from './client-reference' + +globalThis.foo = DynamicComponent + +export default function sitemap() { + return [ + { + url: 'https://acme.com', + lastModified: new Date(), + changeFrequency: 'yearly', + priority: 1, + }, + ] +} diff --git a/test/e2e/app-dir/dynamic/dynamic.test.ts b/test/e2e/app-dir/dynamic/dynamic.test.ts index 15072a7cad403..f1bbcfda64b65 100644 --- a/test/e2e/app-dir/dynamic/dynamic.test.ts +++ b/test/e2e/app-dir/dynamic/dynamic.test.ts @@ -64,6 +64,16 @@ describe('app dir - next/dynamic', () => { expect($('#dynamic-component').text()).not.toContain('loading') }) + it('should ignore next/dynamic in routes', async () => { + const response = await next.fetch('/api') + expect(await response.text()).toEqual('Hello function') + }) + + it('should ignore next/dynamic in sitemap', async () => { + const response = await next.fetch('/sitemap.xml') + expect(await response.text()).toInclude('yearly') + }) + if (isNextDev) { it('should directly raise error when dynamic component error on server', async () => { const pagePath = 'app/default-loading/dynamic-component.js'