Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions crates/next-api/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1134,8 +1134,8 @@ impl AppEndpoint {
next_config: Vc<NextConfig>,
) -> Result<Vc<AppEntry>> {
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?,
Expand Down Expand Up @@ -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 { .. }),
),
};
Expand Down
5 changes: 5 additions & 0 deletions test/e2e/app-dir/dynamic/app/api/route.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { DynamicComponent } from '../client-reference'

export async function GET() {
return new Response('Hello ' + typeof DynamicComponent)
}
5 changes: 5 additions & 0 deletions test/e2e/app-dir/dynamic/app/client-reference.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use client'

import dynamic from 'next/dynamic'

export const DynamicComponent = dynamic(() => import('./dynamic-component'))
7 changes: 7 additions & 0 deletions test/e2e/app-dir/dynamic/app/dynamic-component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const DynamicImportComponent = () => {
return (
<div id="dynamic-component">This is a dynamically imported component</div>
)
}

export default DynamicImportComponent
14 changes: 14 additions & 0 deletions test/e2e/app-dir/dynamic/app/sitemap.js
Original file line number Diff line number Diff line change
@@ -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,
},
]
}
10 changes: 10 additions & 0 deletions test/e2e/app-dir/dynamic/dynamic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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('<changefreq>yearly</changefreq>')
})

if (isNextDev) {
it('should directly raise error when dynamic component error on server', async () => {
const pagePath = 'app/default-loading/dynamic-component.js'
Expand Down
Loading