Skip to content

Commit

Permalink
Merge branch '01-07-_devoverlay_add_pagination' of github.com:vercel/…
Browse files Browse the repository at this point in the history
…next.js into 01-07-_devoverlay_add_pagination
  • Loading branch information
devjiwonchoi committed Jan 10, 2025
2 parents 8955243 + b83b1d5 commit 80bf6e1
Show file tree
Hide file tree
Showing 22 changed files with 267 additions and 103 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

env:
NAPI_CLI_VERSION: 2.16.2
TURBO_VERSION: 2.1.2
TURBO_VERSION: 2.3.3
NODE_LTS_VERSION: 20
CARGO_PROFILE_RELEASE_LTO: 'true'
TURBO_TEAM: 'vercel'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

env:
NAPI_CLI_VERSION: 2.14.7
TURBO_VERSION: 2.1.2
TURBO_VERSION: 2.3.3
NODE_MAINTENANCE_VERSION: 18
NODE_LTS_VERSION: 20
TEST_CONCURRENCY: 8
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ on:

env:
NAPI_CLI_VERSION: 2.14.7
TURBO_VERSION: 2.1.2
TURBO_VERSION: 2.3.3
NODE_LTS_VERSION: 20.9.0
TEST_CONCURRENCY: 8
# disable backtrace for test snapshots
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/code_freeze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ name: Code Freeze

env:
NAPI_CLI_VERSION: 2.14.7
TURBO_VERSION: 2.1.2
TURBO_VERSION: 2.3.3
NODE_LTS_VERSION: 20

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull_request_stats.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name: Generate Pull Request Stats

env:
NAPI_CLI_VERSION: 2.14.7
TURBO_VERSION: 2.1.2
TURBO_VERSION: 2.3.3
NODE_LTS_VERSION: 20
TEST_CONCURRENCY: 6

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/trigger_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ name: Trigger Release

env:
NAPI_CLI_VERSION: 2.14.7
TURBO_VERSION: 2.1.2
TURBO_VERSION: 2.3.3
NODE_LTS_VERSION: 20

jobs:
Expand Down
6 changes: 6 additions & 0 deletions crates/next-core/src/next_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,7 @@ pub struct ExperimentalConfig {
/// @see [api reference](https://nextjs.org/docs/app/api-reference/next-config-js/typedRoutes)
typed_routes: Option<bool>,
url_imports: Option<serde_json::Value>,
view_transition: Option<bool>,
/// This option is to enable running the Webpack build in a worker thread
/// (doesn't apply to Turbopack).
webpack_build_worker: Option<bool>,
Expand Down Expand Up @@ -1396,6 +1397,11 @@ impl NextConfig {
Vc::cell(self.experimental.react_owner_stack.unwrap_or(false))
}

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

#[turbo_tasks::function]
pub fn enable_dynamic_io(&self) -> Vc<bool> {
Vc::cell(self.experimental.dynamic_io.unwrap_or(false))
Expand Down
4 changes: 3 additions & 1 deletion crates/next-core/src/next_import_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ pub async fn get_next_client_import_map(
let react_flavor = if *next_config.enable_ppr().await?
|| *next_config.enable_taint().await?
|| *next_config.enable_react_owner_stack().await?
|| *next_config.enable_view_transition().await?
{
"-experimental"
} else {
Expand Down Expand Up @@ -719,7 +720,8 @@ async fn rsc_aliases(
let ppr = *next_config.enable_ppr().await?;
let taint = *next_config.enable_taint().await?;
let react_owner_stack = *next_config.enable_react_owner_stack().await?;
let react_channel = if ppr || taint || react_owner_stack {
let view_transition = *next_config.enable_view_transition().await?;
let react_channel = if ppr || taint || react_owner_stack || view_transition {
"-experimental"
} else {
""
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@
"taskr": "1.1.0",
"tree-kill": "1.2.2",
"tsec": "0.2.1",
"turbo": "2.1.2",
"turbo": "2.3.3",
"typescript": "5.7.2",
"unfetch": "4.2.0",
"wait-port": "0.2.2",
Expand Down
5 changes: 3 additions & 2 deletions packages/next/src/lib/needs-experimental-react.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { NextConfig } from '../server/config-shared'

export function needsExperimentalReact(config: NextConfig) {
const { ppr, taint, reactOwnerStack } = config.experimental || {}
return Boolean(ppr || taint || reactOwnerStack)
const { ppr, taint, reactOwnerStack, viewTransition } =
config.experimental || {}
return Boolean(ppr || taint || reactOwnerStack || viewTransition)
}
1 change: 1 addition & 0 deletions packages/next/src/server/config-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ export const configSchema: zod.ZodType<NextConfig> = z.lazy(() =>
swcTraceProfiling: z.boolean().optional(),
// NonNullable<webpack.Configuration['experiments']>['buildHttp']
urlImports: z.any().optional(),
viewTransition: z.boolean().optional(),
workerThreads: z.boolean().optional(),
webVitalsAttribution: z
.array(
Expand Down
6 changes: 6 additions & 0 deletions packages/next/src/server/config-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,11 @@ export interface ExperimentalConfig {
*/
useEarlyImport?: boolean

/**
* Enables view transitions by using the {@link https://github.com/facebook/react/pull/31975 unstable_ViewTransition} Component.
*/
viewTransition?: boolean

/**
* Enables `fetch` requests to be proxied to the experimental test proxy server
*/
Expand Down Expand Up @@ -1183,6 +1188,7 @@ export const defaultConfig: NextConfig = {
webpackMemoryOptimizations: false,
optimizeServerReact: true,
useEarlyImport: false,
viewTransition: false,
staleTimes: {
dynamic: 0,
static: 300,
Expand Down
58 changes: 29 additions & 29 deletions pnpm-lock.yaml

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use client'
import * as React from 'react'

export function Toggle() {
const [show, setShow] = React.useState(false)
React.useEffect(() => {
React.startTransition(() => {
setShow(true)
})
}, [])

return (
<div>
<button
onClick={() => {
React.startTransition(() => {
setShow((show) => !show)
})
}}
>
{show ? 'A' : 'B'}
</button>
{show ? <div>hello</div> : <section>Loading</section>}
</div>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { unstable_ViewTransition as ViewTransition } from 'react'
import { Toggle } from './Toggle'

export default function BasicPage() {
return (
<ViewTransition name="page">
<Toggle />
</ViewTransition>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function Root({ children }) {
return (
<html>
<body>{children}</body>
</html>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default function Page() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
experimental: {
viewTransition: true,
},
}
Binary file not shown.
24 changes: 24 additions & 0 deletions test/e2e/app-dir/view-transitions/view-transitions.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import * as path from 'path'
import { nextTestSetup } from 'e2e-utils'
import { BrowserInterface } from 'next-webdriver'

async function assertNoConsoleErrors(browser: BrowserInterface) {
const logs = await browser.log()
const warningsAndErrors = logs.filter((log) => {
return log.source === 'warning' || log.source === 'error'
})

expect(warningsAndErrors).toEqual([])
}

describe('view-transitions', () => {
const { next } = nextTestSetup({
files: path.join(__dirname, 'fixtures/default'),
})

it('smoketest', async () => {
const browser = await next.browser('/basic')

await assertNoConsoleErrors(browser)
})
})
26 changes: 25 additions & 1 deletion turbopack/crates/turbopack-cli/src/arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ use std::{
path::{Path, PathBuf},
};

use clap::{Args, Parser};
use clap::{Args, Parser, ValueEnum};
use serde::{Deserialize, Serialize};
use turbo_tasks::{NonLocalValue, TaskInput};
use turbopack_cli_utils::issue::IssueSeverityCliOption;

#[derive(Debug, Parser)]
Expand All @@ -23,6 +25,24 @@ impl Arguments {
}
}

#[derive(
Copy,
Clone,
Debug,
ValueEnum,
PartialEq,
Eq,
Serialize,
Deserialize,
Hash,
TaskInput,
NonLocalValue,
)]
pub enum Target {
Browser,
Node,
}

#[derive(Debug, Args, Clone)]
pub struct CommonArguments {
/// The entrypoints of the project. Resolved relative to the project's
Expand Down Expand Up @@ -61,6 +81,10 @@ pub struct CommonArguments {
/// MB.
#[clap(long)]
pub memory_limit: Option<usize>,

/// Target
#[clap(long)]
pub target: Option<Target>,
}

#[derive(Debug, Args)]
Expand Down
Loading

0 comments on commit 80bf6e1

Please sign in to comment.