Skip to content

Commit

Permalink
Merge branch 'canary' into cachecontext
Browse files Browse the repository at this point in the history
  • Loading branch information
sebmarkbage authored Sep 30, 2024
2 parents b8b5cbb + aa5d747 commit 85f3ab3
Show file tree
Hide file tree
Showing 26 changed files with 529 additions and 193 deletions.
5 changes: 0 additions & 5 deletions crates/next-core/src/next_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1073,11 +1073,6 @@ impl NextConfig {
Vc::cell(self.experimental.taint.unwrap_or(false))
}

#[turbo_tasks::function]
pub fn enable_dynamic_io(&self) -> Vc<bool> {
Vc::cell(self.experimental.dynamic_io.unwrap_or(false))
}

#[turbo_tasks::function]
pub fn use_swc_css(&self) -> Vc<bool> {
Vc::cell(
Expand Down
21 changes: 7 additions & 14 deletions crates/next-core/src/next_import_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,12 @@ pub async fn get_next_client_import_map(
match ty.into_value() {
ClientContextType::Pages { .. } => {}
ClientContextType::App { app_dir } => {
let react_flavor = if *next_config.enable_ppr().await?
|| *next_config.enable_taint().await?
|| *next_config.enable_dynamic_io().await?
{
"-experimental"
} else {
""
};
let react_flavor =
if *next_config.enable_ppr().await? || *next_config.enable_taint().await? {
"-experimental"
} else {
""
};

import_map.insert_exact_alias(
"react",
Expand Down Expand Up @@ -686,12 +684,7 @@ async fn rsc_aliases(
) -> Result<()> {
let ppr = *next_config.enable_ppr().await?;
let taint = *next_config.enable_taint().await?;
let dynamic_io = *next_config.enable_dynamic_io().await?;
let react_channel = if ppr || taint || dynamic_io {
"-experimental"
} else {
""
};
let react_channel = if ppr || taint { "-experimental" } else { "" };
let react_client_package = get_react_client_package(&next_config).await?;

let mut alias = IndexMap::new();
Expand Down
1 change: 1 addition & 0 deletions packages/next/server.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ export { URLPattern } from 'next/dist/compiled/@edge-runtime/primitives/url'
export { ImageResponse } from 'next/dist/server/web/spec-extension/image-response'
export type { ImageResponseOptions } from 'next/dist/compiled/@vercel/og/types'
export { unstable_after } from 'next/dist/server/after'
export { connection } from 'next/dist/server/request/connection'
export type { UnsafeUnwrappedSearchParams } from 'next/dist/server/request/search-params'
export type { UnsafeUnwrappedParams } from 'next/dist/server/request/params'
2 changes: 2 additions & 0 deletions packages/next/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const serverExports = {
URLPattern: require('next/dist/server/web/spec-extension/url-pattern')
.URLPattern,
unstable_after: require('next/dist/server/after').unstable_after,
connection: require('next/dist/server/request/connection').connection,
}

// https://nodejs.org/api/esm.html#commonjs-namespaces
Expand All @@ -26,3 +27,4 @@ exports.userAgentFromString = serverExports.userAgentFromString
exports.userAgent = serverExports.userAgent
exports.URLPattern = serverExports.URLPattern
exports.unstable_after = serverExports.unstable_after
exports.connection = serverExports.connection
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ export function addSearchParamsToPageSegments(
// If it's a page segment, modify the segment by adding search params
if (segment.includes(PAGE_SEGMENT_KEY)) {
const newSegment = addSearchParamsIfPageSegment(segment, searchParams)
console.log({ existingSegment: segment, newSegment })
return [newSegment, parallelRoutes, ...rest]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ import type {
ChildSegmentMap,
ReadyCacheNode,
} from '../../../shared/lib/app-router-context.shared-runtime'
import {
DEFAULT_SEGMENT_KEY,
PAGE_SEGMENT_KEY,
} from '../../../shared/lib/segment'
import { DEFAULT_SEGMENT_KEY } from '../../../shared/lib/segment'
import { matchSegment } from '../match-segments'
import { createRouterCacheKey } from './create-router-cache-key'
import type { FetchServerResponseResult } from './fetch-server-response'
Expand Down Expand Up @@ -124,27 +121,13 @@ export function updateCacheNodeOnNavigation(
const oldSegmentChild =
oldRouterStateChild !== undefined ? oldRouterStateChild[0] : undefined

// A dynamic segment will be an array, and doesn't correspond with a page segment.
const isPageSegment = Array.isArray(newSegmentChild)
? false
: // A page segment might contain search parameters, so we verify that it starts with the page segment key.
newSegmentChild.startsWith(PAGE_SEGMENT_KEY)

const oldCacheNodeChild =
oldSegmentMapChild !== undefined
? oldSegmentMapChild.get(newSegmentKeyChild)
: undefined

let taskChild: Task | null
if (isPageSegment) {
// This is a leaf segment — a page, not a shared layout. We always apply
// its data.
taskChild = spawnPendingTask(
newRouterStateChild,
prefetchDataChild !== undefined ? prefetchDataChild : null,
prefetchHead
)
} else if (newSegmentChild === DEFAULT_SEGMENT_KEY) {
if (newSegmentChild === DEFAULT_SEGMENT_KEY) {
// This is another kind of leaf segment — a default route.
//
// Default routes have special behavior. When there's no matching segment
Expand Down
6 changes: 1 addition & 5 deletions packages/next/src/lib/needs-experimental-react.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import type { NextConfig } from '../server/config-shared'

export function needsExperimentalReact(config: NextConfig) {
return Boolean(
config.experimental?.ppr ||
config.experimental?.taint ||
config.experimental?.dynamicIO
)
return Boolean(config.experimental?.ppr || config.experimental?.taint)
}
1 change: 1 addition & 0 deletions packages/next/src/server/app-render/action-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,7 @@ export async function handleAction({
if (isMultipartAction) {
if (isFetchAction) {
const busboy = (require('busboy') as typeof import('busboy'))({
defParamCharset: 'utf8',
headers: req.headers,
limits: { fieldSize: bodySizeLimitBytes },
})
Expand Down
Loading

0 comments on commit 85f3ab3

Please sign in to comment.