Skip to content

Commit

Permalink
Merge branch 'canary' into huozhi/remove-rsc-client-ref-exports
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi authored May 9, 2024
2 parents 95d2973 + bd110c6 commit f2c5927
Show file tree
Hide file tree
Showing 28 changed files with 148 additions and 148 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,7 @@ export default async function sitemap({ id }) {
}
```

In production, your generated sitemaps will be available at `/.../sitemap/[id].xml`. For example, `/product/sitemap/1.xml`.

In development, you can view the generated sitemap on `/.../sitemap.xml/[id]`. For example, `/product/sitemap.xml/1`. This difference is temporary and will follow the production format.
Your generated sitemaps will be available at `/.../sitemap/[id]`. For example, `/product/sitemap/1`.

See the [`generateSitemaps` API reference](/docs/app/api-reference/functions/generate-sitemaps) for more information.

Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
"registry": "https://registry.npmjs.org/"
}
},
"version": "14.3.0-canary.51"
"version": "14.3.0-canary.52"
}
2 changes: 1 addition & 1 deletion packages/create-next-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-next-app",
"version": "14.3.0-canary.51",
"version": "14.3.0-canary.52",
"keywords": [
"react",
"next",
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-config-next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-config-next",
"version": "14.3.0-canary.51",
"version": "14.3.0-canary.52",
"description": "ESLint configuration used by Next.js.",
"main": "index.js",
"license": "MIT",
Expand All @@ -10,7 +10,7 @@
},
"homepage": "https://nextjs.org/docs/app/building-your-application/configuring/eslint#eslint-config",
"dependencies": {
"@next/eslint-plugin-next": "14.3.0-canary.51",
"@next/eslint-plugin-next": "14.3.0-canary.52",
"@rushstack/eslint-patch": "^1.3.3",
"@typescript-eslint/parser": "^5.4.2 || ^6.0.0 || 7.0.0 - 7.2.0",
"eslint-import-resolver-node": "^0.3.6",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/eslint-plugin-next",
"version": "14.3.0-canary.51",
"version": "14.3.0-canary.52",
"description": "ESLint plugin for Next.js.",
"main": "dist/index.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/font/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/font",
"version": "14.3.0-canary.51",
"version": "14.3.0-canary.52",
"repository": {
"url": "vercel/next.js",
"directory": "packages/font"
Expand Down
2 changes: 1 addition & 1 deletion packages/next-bundle-analyzer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/bundle-analyzer",
"version": "14.3.0-canary.51",
"version": "14.3.0-canary.52",
"main": "index.js",
"types": "index.d.ts",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-codemod/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/codemod",
"version": "14.3.0-canary.51",
"version": "14.3.0-canary.52",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-env/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/env",
"version": "14.3.0-canary.51",
"version": "14.3.0-canary.52",
"keywords": [
"react",
"next",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-mdx/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/mdx",
"version": "14.3.0-canary.51",
"version": "14.3.0-canary.52",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-plugin-storybook/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-storybook",
"version": "14.3.0-canary.51",
"version": "14.3.0-canary.52",
"repository": {
"url": "vercel/next.js",
"directory": "packages/next-plugin-storybook"
Expand Down
2 changes: 1 addition & 1 deletion packages/next-polyfill-module/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/polyfill-module",
"version": "14.3.0-canary.51",
"version": "14.3.0-canary.52",
"description": "A standard library polyfill for ES Modules supporting browsers (Edge 16+, Firefox 60+, Chrome 61+, Safari 10.1+)",
"main": "dist/polyfill-module.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-polyfill-nomodule/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/polyfill-nomodule",
"version": "14.3.0-canary.51",
"version": "14.3.0-canary.52",
"description": "A polyfill for non-dead, nomodule browsers.",
"main": "dist/polyfill-nomodule.js",
"license": "MIT",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,8 @@ pub fn normalize_metadata_route(mut page: AppPage) -> Result<AppPage> {
route += ".txt"
} else if route == "/manifest" {
route += ".webmanifest"
} else if route.ends_with("/sitemap") {
route += ".xml"
} else {
// Do not append the suffix for the sitemap route
} else if !route.ends_with("/sitemap") {
// Remove the file extension, e.g. /route-path/robots.txt -> /route-path
let pathname_prefix = split_directory(&route).0.unwrap_or_default();
suffix = get_metadata_route_suffix(pathname_prefix);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ async fn dynamic_site_map_route_source(
const params = []
for (const item of sitemaps) {
params.push({ __metadata_id__: item.id.toString() + '.xml' })
params.push({ __metadata_id__: item.id.toString() })
}
return params
}
Expand Down
2 changes: 1 addition & 1 deletion packages/next-swc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/swc",
"version": "14.3.0-canary.51",
"version": "14.3.0-canary.52",
"private": true,
"scripts": {
"clean": "node ../../scripts/rm.mjs native",
Expand Down
12 changes: 6 additions & 6 deletions packages/next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next",
"version": "14.3.0-canary.51",
"version": "14.3.0-canary.52",
"description": "The React Framework",
"main": "./dist/server/next.js",
"license": "MIT",
Expand Down Expand Up @@ -93,7 +93,7 @@
]
},
"dependencies": {
"@next/env": "14.3.0-canary.51",
"@next/env": "14.3.0-canary.52",
"@swc/helpers": "0.5.11",
"busboy": "1.6.0",
"caniuse-lite": "^1.0.30001579",
Expand Down Expand Up @@ -153,10 +153,10 @@
"@jest/types": "29.5.0",
"@mswjs/interceptors": "0.23.0",
"@napi-rs/triples": "1.2.0",
"@next/polyfill-module": "14.3.0-canary.51",
"@next/polyfill-nomodule": "14.3.0-canary.51",
"@next/react-refresh-utils": "14.3.0-canary.51",
"@next/swc": "14.3.0-canary.51",
"@next/polyfill-module": "14.3.0-canary.52",
"@next/polyfill-nomodule": "14.3.0-canary.52",
"@next/react-refresh-utils": "14.3.0-canary.52",
"@next/swc": "14.3.0-canary.52",
"@opentelemetry/api": "1.6.0",
"@playwright/test": "1.41.2",
"@taskr/clear": "1.1.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/next/src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -998,13 +998,13 @@ export default async function build(
}

if (
pageKey.includes('sitemap.xml/[[...__metadata_id__]]') &&
pageKey.includes('sitemap/[[...__metadata_id__]]') &&
isDynamic
) {
delete mappedAppPages[pageKey]
mappedAppPages[
pageKey.replace(
'sitemap.xml/[[...__metadata_id__]]',
'sitemap/[[...__metadata_id__]]',
'sitemap/[__metadata_id__]'
)
] = pagePath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export async function generateStaticParams() {
const params = []
for (const item of sitemaps) {
params.push({ __metadata_id__: item.id.toString() + '.xml' })
params.push({ __metadata_id__: item.id.toString() })
}
return params
}
Expand Down Expand Up @@ -225,9 +225,6 @@ export async function GET(_, ctx) {
}
}
let itemID = item.id.toString()
if(process.env.NODE_ENV === 'production') {
itemID += '.xml'
}
return itemID === targetId
})?.id
if (id == null) {
Expand Down
6 changes: 3 additions & 3 deletions packages/next/src/lib/metadata/get-metadata-route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ export function normalizeMetadataRoute(page: string) {
route += '.txt'
} else if (page === '/manifest') {
route += '.webmanifest'
} else if (page.endsWith('/sitemap')) {
route += '.xml'
} else {
}
// For sitemap, we don't automatically add the route suffix since it can have sub-routes
else if (!page.endsWith('/sitemap')) {
// Remove the file extension, e.g. /route-path/robots.txt -> /route-path
const pathnamePrefix = page.slice(0, -(path.basename(page).length + 1))
suffix = getMetadataRouteSuffix(pathnamePrefix)
Expand Down
2 changes: 1 addition & 1 deletion packages/react-refresh-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/react-refresh-utils",
"version": "14.3.0-canary.51",
"version": "14.3.0-canary.52",
"description": "An experimental package providing utilities for React Refresh.",
"repository": {
"url": "vercel/next.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/third-parties/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/third-parties",
"version": "14.3.0-canary.51",
"version": "14.3.0-canary.52",
"repository": {
"url": "vercel/next.js",
"directory": "packages/third-parties"
Expand All @@ -26,7 +26,7 @@
"third-party-capital": "1.0.20"
},
"devDependencies": {
"next": "14.3.0-canary.51",
"next": "14.3.0-canary.52",
"outdent": "0.8.0",
"prettier": "2.5.1"
},
Expand Down
14 changes: 7 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion test/.stats-app/pages/dynamic.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import dynamic from 'next/dynamic'

const DynamicHello = dynamic(() => import('../components/hello'))
const DynamicHello = dynamic(() =>
import('../components/hello').then((mod) => mod.Hello)
)

const Page = () => (
<>
Expand Down
35 changes: 18 additions & 17 deletions test/e2e/app-dir/dynamic-in-generate-params/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,39 +1,40 @@
import { type NextInstance, nextTestSetup } from 'e2e-utils'
import type { Response } from 'node-fetch'

async function getLastModifiedTime(next: NextInstance, pathname: string) {
const content = await (await next.fetch(pathname)).text()
return content.match(/<lastmod>([^<]+)<\/lastmod>/)[1]
}

function assertSitemapResponse(res: Response) {
expect(res.status).toBe(200)
expect(res.headers.get('content-type')).toContain('application/xml')
}

describe('app-dir - dynamic in generate params', () => {
const { next, isNextDev } = nextTestSetup({
const { next } = nextTestSetup({
files: __dirname,
skipDeployment: true,
})

it('should render sitemap with generateSitemaps in force-dynamic config dynamically', async () => {
const firstTime = await getLastModifiedTime(
next,
isNextDev ? 'sitemap.xml/0' : '/sitemap/0.xml'
)
const secondTime = await getLastModifiedTime(
next,
isNextDev ? 'sitemap.xml/0' : '/sitemap/0.xml'
)
const firstTime = await getLastModifiedTime(next, 'sitemap/0')
const secondTime = await getLastModifiedTime(next, 'sitemap/0')

expect(firstTime).not.toEqual(secondTime)
})

it('should be able to call while generating multiple dynamic sitemaps', async () => {
expect(
(await next.fetch(isNextDev ? 'sitemap.xml/0' : '/sitemap/0.xml')).status
).toBe(200)
expect(
(await next.fetch(isNextDev ? 'sitemap.xml/1' : '/sitemap/1.xml')).status
).toBe(200)
const res0 = await next.fetch('sitemap/0')
const res1 = await next.fetch('sitemap/1')
assertSitemapResponse(res0)
assertSitemapResponse(res1)
})

it('should be able to call fetch while generating multiple dynamic pages', async () => {
expect((await next.fetch('/dynamic/0')).status).toBe(200)
expect((await next.fetch('/dynamic/1')).status).toBe(200)
const pageRes0 = await next.fetch('dynamic/0')
const pageRes1 = await next.fetch('dynamic/1')
expect(pageRes0.status).toBe(200)
expect(pageRes1.status).toBe(200)
})
})
Loading

0 comments on commit f2c5927

Please sign in to comment.