Skip to content

Commit

Permalink
Merge branch 'canary' into fix/swc-optimize-node-modules
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Feb 14, 2024
2 parents bd96d5a + ea65cb6 commit f844b99
Show file tree
Hide file tree
Showing 56 changed files with 338 additions and 722 deletions.
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.1.1-canary.52"
"version": "14.1.1-canary.53"
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@
"open": "9.0.0",
"outdent": "0.8.0",
"pixrem": "5.0.0",
"playwright-chromium": "1.35.1",
"playwright-core": "1.35.1",
"playwright": "1.41.2",
"playwright-chromium": "1.41.2",
"postcss": "8.4.31",
"postcss-nested": "4.2.1",
"postcss-pseudoelements": "5.0.0",
Expand Down
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.1.1-canary.52",
"version": "14.1.1-canary.53",
"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.1.1-canary.52",
"version": "14.1.1-canary.53",
"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.1.1-canary.52",
"@next/eslint-plugin-next": "14.1.1-canary.53",
"@rushstack/eslint-patch": "^1.3.3",
"@typescript-eslint/parser": "^5.4.2 || ^6.0.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.1.1-canary.52",
"version": "14.1.1-canary.53",
"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.1.1-canary.52",
"version": "14.1.1-canary.53",
"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.1.1-canary.52",
"version": "14.1.1-canary.53",
"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.1.1-canary.52",
"version": "14.1.1-canary.53",
"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.1.1-canary.52",
"version": "14.1.1-canary.53",
"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.1.1-canary.52",
"version": "14.1.1-canary.53",
"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.1.1-canary.52",
"version": "14.1.1-canary.53",
"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.1.1-canary.52",
"version": "14.1.1-canary.53",
"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.1.1-canary.52",
"version": "14.1.1-canary.53",
"description": "A polyfill for non-dead, nomodule browsers.",
"main": "dist/polyfill-nomodule.js",
"license": "MIT",
Expand Down
3 changes: 3 additions & 0 deletions packages/next-swc/crates/next-core/src/next_import_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,9 @@ async fn rsc_aliases(
"react-server-dom-webpack/server.node" => format!("next/dist/server/future/route-modules/app-page/vendored/rsc/react-server-dom-turbopack-server-node"),
"react-server-dom-turbopack/server.edge" => format!("next/dist/server/future/route-modules/app-page/vendored/rsc/react-server-dom-turbopack-server-edge"),
"react-server-dom-turbopack/server.node" => format!("next/dist/server/future/route-modules/app-page/vendored/rsc/react-server-dom-turbopack-server-node"),

// Needed to make `react-dom/server` work.
"next/dist/compiled/react" => format!("next/dist/compiled/react/index.js"),
})
}
}
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.1.1-canary.52",
"version": "14.1.1-canary.53",
"private": true,
"scripts": {
"clean": "node ../../scripts/rm.mjs native",
Expand Down
16 changes: 8 additions & 8 deletions packages/next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next",
"version": "14.1.1-canary.52",
"version": "14.1.1-canary.53",
"description": "The React Framework",
"main": "./dist/server/next.js",
"license": "MIT",
Expand Down Expand Up @@ -92,7 +92,7 @@
]
},
"dependencies": {
"@next/env": "14.1.1-canary.52",
"@next/env": "14.1.1-canary.53",
"@swc/helpers": "0.5.5",
"busboy": "1.6.0",
"caniuse-lite": "^1.0.30001579",
Expand Down Expand Up @@ -145,12 +145,12 @@
"@jest/types": "29.5.0",
"@mswjs/interceptors": "0.23.0",
"@napi-rs/triples": "1.2.0",
"@next/polyfill-module": "14.1.1-canary.52",
"@next/polyfill-nomodule": "14.1.1-canary.52",
"@next/react-refresh-utils": "14.1.1-canary.52",
"@next/swc": "14.1.1-canary.52",
"@next/polyfill-module": "14.1.1-canary.53",
"@next/polyfill-nomodule": "14.1.1-canary.53",
"@next/react-refresh-utils": "14.1.1-canary.53",
"@next/swc": "14.1.1-canary.53",
"@opentelemetry/api": "1.6.0",
"@playwright/test": "^1.35.1",
"@playwright/test": "1.41.2",
"@taskr/clear": "1.1.0",
"@taskr/esnext": "1.1.0",
"@types/amphtml-validator": "1.0.0",
Expand Down Expand Up @@ -309,7 +309,7 @@
"vm-browserify": "1.1.2",
"watchpack": "2.4.0",
"web-vitals": "3.0.0",
"webpack": "5.86.0",
"webpack": "5.90.0",
"webpack-sources1": "npm:webpack-sources@1.4.3",
"webpack-sources3": "npm:webpack-sources@3.2.3",
"ws": "8.2.3",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { FlightRouterState } from '../../../server/app-render/types'
import { GLOBAL_NOT_FOUND_SEGMENT_KEY } from '../../../shared/lib/segment'

export function isNavigatingToNewRootLayout(
currentTree: FlightRouterState,
Expand All @@ -7,6 +8,10 @@ export function isNavigatingToNewRootLayout(
// Compare segments
const currentTreeSegment = currentTree[0]
const nextTreeSegment = nextTree[0]

// We currently special-case the global not found segment key, but we don't want it to be treated as a root layout change
if (currentTreeSegment === GLOBAL_NOT_FOUND_SEGMENT_KEY) return false

// If any segment is different before we find the root layout, the root layout has changed.
// E.g. /same/(group1)/layout.js -> /same/(group2)/layout.js
// First segment is 'same' for both, keep looking. (group1) changed to (group2) before the root layout was found, it must have changed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ import { handleMutable } from '../handle-mutable'
import { applyFlightData } from '../apply-flight-data'
import { prefetchQueue } from './prefetch-reducer'
import { createEmptyCacheNode } from '../../app-router'
import { DEFAULT_SEGMENT_KEY } from '../../../../shared/lib/segment'
import {
DEFAULT_SEGMENT_KEY,
GLOBAL_NOT_FOUND_SEGMENT_KEY,
} from '../../../../shared/lib/segment'
import {
listenForDynamicRequest,
updateCacheNodeOnNavigation,
Expand Down Expand Up @@ -202,7 +205,10 @@ function navigateReducer_noPPR(

if (
!applied &&
prefetchEntryCacheStatus === PrefetchCacheEntryStatus.stale
(prefetchEntryCacheStatus === PrefetchCacheEntryStatus.stale ||
// if we've navigated away from the global not found segment but didn't apply the flight data, we need to refetch
// as otherwise we'd be incorrectly using the global not found cache node for the incoming page
currentTree[0] === GLOBAL_NOT_FOUND_SEGMENT_KEY)
) {
applied = addRefetchToLeafSegments(
cache,
Expand Down Expand Up @@ -454,7 +460,10 @@ function navigateReducer_PPR(

if (
!applied &&
prefetchEntryCacheStatus === PrefetchCacheEntryStatus.stale
(prefetchEntryCacheStatus === PrefetchCacheEntryStatus.stale ||
// if we've navigated away from the global not found segment but didn't apply the flight data, we need to refetch
// as otherwise we'd be incorrectly using the global not found cache node for the incoming page
currentTree[0] === GLOBAL_NOT_FOUND_SEGMENT_KEY)
) {
applied = addRefetchToLeafSegments(
cache,
Expand Down
11 changes: 11 additions & 0 deletions packages/next/src/server/app-render/app-render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ import {
usedDynamicAPIs,
createPostponedAbortSignal,
} from './dynamic-rendering'
import { GLOBAL_NOT_FOUND_SEGMENT_KEY } from '../../shared/lib/segment'

export type GetDynamicParamFromSegment = (
// [slug] / [[slug]] / [...slug]
Expand Down Expand Up @@ -405,6 +406,16 @@ async function ReactServerApp({ tree, ctx, asNotFound }: ReactServerAppProps) {
query
)

// If the page we're rendering is being treated as the global not-found page, we want to special-case
// the segment key so it doesn't collide with a page matching the same path.
// This is necessary because when rendering the global not-found, it will always be the root segment.
// If the not-found page prefetched a link to the root page, it would have the same data path
// (e.g., ['', { children: ['__PAGE__', {}] }]). Without this disambiguation, the router would interpret
// these pages as being able to share the same cache nodes, which is not the case as they render different things.
if (asNotFound) {
initialTree[0] = GLOBAL_NOT_FOUND_SEGMENT_KEY
}

const [MetadataTree, MetadataOutlet] = createMetadataComponents({
tree,
errorType: asNotFound ? 'not-found' : undefined,
Expand Down
1 change: 1 addition & 0 deletions packages/next/src/shared/lib/segment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export function isGroupSegment(segment: string) {

export const PAGE_SEGMENT_KEY = '__PAGE__'
export const DEFAULT_SEGMENT_KEY = '__DEFAULT__'
export const GLOBAL_NOT_FOUND_SEGMENT_KEY = '__NOT_FOUND__'
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.1.1-canary.52",
"version": "14.1.1-canary.53",
"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.1.1-canary.52",
"version": "14.1.1-canary.53",
"repository": {
"url": "vercel/next.js",
"directory": "packages/third-parties"
Expand All @@ -26,7 +26,7 @@
"third-party-capital": "1.0.20"
},
"devDependencies": {
"next": "14.1.1-canary.52",
"next": "14.1.1-canary.53",
"outdent": "0.8.0",
"prettier": "2.5.1"
},
Expand Down

0 comments on commit f844b99

Please sign in to comment.