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
4 changes: 4 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,7 @@ jobs:
# Keep Next.js related env variables in sync with additionalEnv in next-deploy.ts
afterBuild: |
export __NEXT_CACHE_COMPONENTS=true
export __NEXT_EXPERIMENTAL_APP_NEW_SCROLL_HANDLER=true
export __NEXT_EXPERIMENTAL_DEBUG_CHANNEL=true
export NEXT_EXTERNAL_TESTS_FILTERS="test/deploy-tests-manifest.json,test/cache-components-tests-manifest.json"
export NEXT_E2E_TEST_TIMEOUT=240000
Expand Down Expand Up @@ -962,6 +963,7 @@ jobs:
nodeVersion: 20.9.0
afterBuild: |
export __NEXT_CACHE_COMPONENTS=true
export __NEXT_EXPERIMENTAL_APP_NEW_SCROLL_HANDLER=true
export __NEXT_EXPERIMENTAL_DEBUG_CHANNEL=true
export NEXT_EXTERNAL_TESTS_FILTERS="test/cache-components-tests-manifest.json"
export IS_WEBPACK_TEST=1
Expand All @@ -985,6 +987,7 @@ jobs:
with:
afterBuild: |
export __NEXT_CACHE_COMPONENTS=true
export __NEXT_EXPERIMENTAL_APP_NEW_SCROLL_HANDLER=true
export __NEXT_EXPERIMENTAL_DEBUG_CHANNEL=true
export NEXT_EXTERNAL_TESTS_FILTERS="test/cache-components-tests-manifest.json"
export NEXT_TEST_MODE=dev
Expand All @@ -1010,6 +1013,7 @@ jobs:
with:
afterBuild: |
export __NEXT_CACHE_COMPONENTS=true
export __NEXT_EXPERIMENTAL_APP_NEW_SCROLL_HANDLER=true
export __NEXT_EXPERIMENTAL_DEBUG_CHANNEL=true
export NEXT_EXTERNAL_TESTS_FILTERS="test/cache-components-tests-manifest.json"
export NEXT_TEST_MODE=start
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 @@ -1095,6 +1095,7 @@ pub struct ExperimentalConfig {
adjust_font_fallbacks_with_size_adjust: Option<bool>,
after: Option<bool>,
app_document_preloading: Option<bool>,
app_new_scroll_handler: Option<bool>,
case_sensitive_routes: Option<bool>,
cpus: Option<f64>,
cra_compat: Option<bool>,
Expand Down Expand Up @@ -1913,6 +1914,11 @@ impl NextConfig {
Vc::cell(self.experimental.gesture_transition.unwrap_or(false))
}

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

#[turbo_tasks::function]
pub fn enable_cache_components(&self) -> Vc<bool> {
Vc::cell(self.cache_components.unwrap_or(false))
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
"test-storybook": "turbo run test-storybook",
"with-rspack": "cross-env NEXT_RSPACK=1 NEXT_TEST_USE_RSPACK=1",
"with-webpack": "cross-env IS_WEBPACK_TEST=1",
"with-experimental": "cross-env __NEXT_CACHE_COMPONENTS=true __NEXT_EXPERIMENTAL_DEBUG_CHANNEL=true"
"with-experimental": "cross-env __NEXT_CACHE_COMPONENTS=true __NEXT_EXPERIMENTAL_APP_NEW_SCROLL_HANDLER=true __NEXT_EXPERIMENTAL_DEBUG_CHANNEL=true"
},
"devDependencies": {
"@actions/core": "1.10.1",
Expand Down
3 changes: 3 additions & 0 deletions packages/next/src/build/define-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ export function getDefineEnv({
'process.env.__NEXT_APP_NAV_FAIL_HANDLING': Boolean(
config.experimental.appNavFailHandling
),
'process.env.__NEXT_APP_NEW_SCROLL_HANDLER': Boolean(
config.experimental.appNewScrollHandler
),
'process.env.__NEXT_PPR': isPPREnabled,
'process.env.__NEXT_CACHE_COMPONENTS': isCacheComponentsEnabled,
'process.env.__NEXT_USE_CACHE': isUseCacheEnabled,
Expand Down
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 @@ -182,6 +182,7 @@ export const experimentalSchema = {
useSkewCookie: z.boolean().optional(),
after: z.boolean().optional(),
appNavFailHandling: z.boolean().optional(),
appNewScrollHandler: z.boolean().optional(),
preloadEntriesOnStart: z.boolean().optional(),
allowedRevalidateHeaderKeys: z.array(z.string()).optional(),
staleTimes: z
Expand Down
2 changes: 2 additions & 0 deletions packages/next/src/server/config-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ export interface LoggingConfig {

export interface ExperimentalConfig {
adapterPath?: string
appNewScrollHandler?: boolean
useSkewCookie?: boolean
/** @deprecated use top-level `cacheHandlers` instead */
cacheHandlers?: NextConfig['cacheHandlers']
Expand Down Expand Up @@ -1617,6 +1618,7 @@ export const defaultConfig = Object.freeze({
},
experimental: {
adapterPath: process.env.NEXT_ADAPTER_PATH || undefined,
appNewScrollHandler: false,
useSkewCookie: false,
cssChunking: true,
multiZoneDraftMode: false,
Expand Down
19 changes: 19 additions & 0 deletions packages/next/src/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1906,6 +1906,25 @@ function enforceExperimentalFeatures(
config.cacheComponents = true
}

// TODO: Remove this once appNewScrollHandler is the default.
if (
process.env.__NEXT_EXPERIMENTAL_APP_NEW_SCROLL_HANDLER === 'true' &&
// We do respect an explicit value in the user config.
(config.experimental.appNewScrollHandler === undefined ||
(isDefaultConfig && !config.experimental.appNewScrollHandler))
) {
config.experimental.appNewScrollHandler = true

if (configuredExperimentalFeatures) {
addConfiguredExperimentalFeature(
configuredExperimentalFeatures,
'appNewScrollHandler',
true,
'enabled by `__NEXT_EXPERIMENTAL_APP_NEW_SCROLL_HANDLER`'
)
}
}

// TODO: Remove this once using the debug channel is the default.
if (
process.env.__NEXT_EXPERIMENTAL_DEBUG_CHANNEL === 'true' &&
Expand Down
3 changes: 3 additions & 0 deletions test/lib/next-modes/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,9 @@ export class NextInstance {
if (process.env.NEXT_PRIVATE_EXPERIMENTAL_CACHE_COMPONENTS) {
process.env.__NEXT_CACHE_COMPONENTS = process.env.NEXT_PRIVATE_EXPERIMENTAL_CACHE_COMPONENTS
}
if (process.env.NEXT_PRIVATE_EXPERIMENTAL_APP_NEW_SCROLL_HANDLER) {
process.env.__NEXT_EXPERIMENTAL_APP_NEW_SCROLL_HANDLER = process.env.NEXT_PRIVATE_EXPERIMENTAL_APP_NEW_SCROLL_HANDLER
}
if (process.env.NEXT_PRIVATE_EXPERIMENTAL_DEBUG_CHANNEL) {
process.env.__NEXT_EXPERIMENTAL_DEBUG_CHANNEL = process.env.NEXT_PRIVATE_EXPERIMENTAL_DEBUG_CHANNEL
}
Expand Down
5 changes: 5 additions & 0 deletions test/lib/next-modes/next-deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,11 @@ export class NextDeployInstance extends NextInstance {
`NEXT_PRIVATE_EXPERIMENTAL_CACHE_COMPONENTS=${process.env.__NEXT_CACHE_COMPONENTS}`
)
}
if (process.env.__NEXT_EXPERIMENTAL_APP_NEW_SCROLL_HANDLER) {
additionalEnv.push(
`NEXT_PRIVATE_EXPERIMENTAL_APP_NEW_SCROLL_HANDLER=${process.env.__NEXT_EXPERIMENTAL_APP_NEW_SCROLL_HANDLER}`
)
}
if (process.env.__NEXT_EXPERIMENTAL_DEBUG_CHANNEL) {
additionalEnv.push(
`NEXT_PRIVATE_EXPERIMENTAL_DEBUG_CHANNEL=${process.env.__NEXT_EXPERIMENTAL_DEBUG_CHANNEL}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ describe('build-output-prerender', () => {
expect(getPreambleOutput(next.cliOutput)).toMatchInlineSnapshot(`
"▲ Next.js x.y.z (Turbopack, Cache Components)
- Experiments (use with caution):
✓ appNewScrollHandler (enabled by \`__NEXT_EXPERIMENTAL_APP_NEW_SCROLL_HANDLER\`)
✓ reactDebugChannel (enabled by \`__NEXT_EXPERIMENTAL_DEBUG_CHANNEL\`)"
`)
} else {
expect(getPreambleOutput(next.cliOutput)).toMatchInlineSnapshot(`
"▲ Next.js x.y.z (webpack)
- Cache Components enabled
- Experiments (use with caution):
✓ appNewScrollHandler (enabled by \`__NEXT_EXPERIMENTAL_APP_NEW_SCROLL_HANDLER\`)
✓ reactDebugChannel (enabled by \`__NEXT_EXPERIMENTAL_DEBUG_CHANNEL\`)"
`)
}
Expand Down Expand Up @@ -101,6 +103,7 @@ describe('build-output-prerender', () => {
"⚠ Prerendering is running in debug mode. Note: This may affect performance and should not be used for production.
▲ Next.js x.y.z (Turbopack, Cache Components)
- Experiments (use with caution):
✓ appNewScrollHandler (enabled by \`__NEXT_EXPERIMENTAL_APP_NEW_SCROLL_HANDLER\`)
⨯ prerenderEarlyExit (disabled by \`--debug-prerender\`)
✓ reactDebugChannel (enabled by \`__NEXT_EXPERIMENTAL_DEBUG_CHANNEL\`)
✓ serverSourceMaps (enabled by \`--debug-prerender\`)
Expand All @@ -112,6 +115,7 @@ describe('build-output-prerender', () => {
▲ Next.js x.y.z (webpack)
- Cache Components enabled
- Experiments (use with caution):
✓ appNewScrollHandler (enabled by \`__NEXT_EXPERIMENTAL_APP_NEW_SCROLL_HANDLER\`)
⨯ prerenderEarlyExit (disabled by \`--debug-prerender\`)
✓ reactDebugChannel (enabled by \`__NEXT_EXPERIMENTAL_DEBUG_CHANNEL\`)
⨯ serverMinification (disabled by \`--debug-prerender\`)
Expand Down Expand Up @@ -230,13 +234,15 @@ describe('build-output-prerender', () => {
expect(getPreambleOutput(next.cliOutput)).toMatchInlineSnapshot(`
"▲ Next.js x.y.z (Turbopack, Cache Components)
- Experiments (use with caution):
✓ appNewScrollHandler (enabled by \`__NEXT_EXPERIMENTAL_APP_NEW_SCROLL_HANDLER\`)
✓ reactDebugChannel (enabled by \`__NEXT_EXPERIMENTAL_DEBUG_CHANNEL\`)"
`)
} else {
expect(getPreambleOutput(next.cliOutput)).toMatchInlineSnapshot(`
"▲ Next.js x.y.z (webpack)
- Cache Components enabled
- Experiments (use with caution):
✓ appNewScrollHandler (enabled by \`__NEXT_EXPERIMENTAL_APP_NEW_SCROLL_HANDLER\`)
✓ reactDebugChannel (enabled by \`__NEXT_EXPERIMENTAL_DEBUG_CHANNEL\`)"
`)
}
Expand Down Expand Up @@ -278,6 +284,7 @@ describe('build-output-prerender', () => {
"⚠ Prerendering is running in debug mode. Note: This may affect performance and should not be used for production.
▲ Next.js x.y.z (Turbopack, Cache Components)
- Experiments (use with caution):
✓ appNewScrollHandler (enabled by \`__NEXT_EXPERIMENTAL_APP_NEW_SCROLL_HANDLER\`)
⨯ prerenderEarlyExit (disabled by \`--debug-prerender\`)
✓ reactDebugChannel (enabled by \`__NEXT_EXPERIMENTAL_DEBUG_CHANNEL\`)
✓ serverSourceMaps (enabled by \`--debug-prerender\`)
Expand All @@ -289,6 +296,7 @@ describe('build-output-prerender', () => {
▲ Next.js x.y.z (webpack)
- Cache Components enabled
- Experiments (use with caution):
✓ appNewScrollHandler (enabled by \`__NEXT_EXPERIMENTAL_APP_NEW_SCROLL_HANDLER\`)
⨯ prerenderEarlyExit (disabled by \`--debug-prerender\`)
✓ reactDebugChannel (enabled by \`__NEXT_EXPERIMENTAL_DEBUG_CHANNEL\`)
⨯ serverMinification (disabled by \`--debug-prerender\`)
Expand Down
Loading