Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
ad4f5ce5
Commit
ad4f5ce5
authored
Dec 08, 2025
by
Jude Gao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve ux
parent
961fb0ae
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
344 additions
and
517 deletions
+344
-517
next.ts
packages/next/src/bin/next.ts
+2
-2
build-context.ts
packages/next/src/build/build-context.ts
+1
-1
define-env.ts
packages/next/src/build/define-env.ts
+1
-1
index.ts
packages/next/src/build/index.ts
+3
-3
impl.ts
packages/next/src/build/turbopack-build/impl.ts
+1
-1
impl.ts
packages/next/src/build/webpack-build/impl.ts
+1
-1
webpack-config.ts
packages/next/src/build/webpack-config.ts
+2
-2
next-build.ts
packages/next/src/cli/next-build.ts
+5
-5
app-bootstrap.ts
packages/next/src/client/app-bootstrap.ts
+3
-3
index.tsx
packages/next/src/client/index.tsx
+3
-3
waterfall-detector.ts
packages/next/src/client/waterfall-detector.ts
+69
-298
require-instrumentation-client.ts
packages/next/src/lib/require-instrumentation-client.ts
+1
-1
config-shared.ts
packages/next/src/server/config-shared.ts
+6
-6
config.ts
packages/next/src/server/config.ts
+13
-13
app-info-log.ts
packages/next/src/server/lib/app-info-log.ts
+10
-0
start-server.ts
packages/next/src/server/lib/start-server.ts
+8
-0
next-server.ts
packages/next/src/server/next-server.ts
+215
-177
No files found.
packages/next/src/bin/next.ts
View file @
ad4f5ce5
...
...
@@ -187,8 +187,8 @@ program
'Comma-separated glob patterns or explicit paths for selective builds. Examples: "app/*", "app/page.tsx", "app/**/page.tsx"'
)
.
option
(
'--
profiler
'
,
'Creates a
profiler
build with source maps enabled, no minification, and React profiling.'
'--
insights
'
,
'Creates a
n insights
build with source maps enabled, no minification, and React profiling.'
)
.
action
((
directory
:
string
,
options
:
NextBuildOptions
)
=>
{
if
(
options
.
experimentalNextConfigStripTypes
)
{
...
...
packages/next/src/build/build-context.ts
View file @
ad4f5ce5
...
...
@@ -96,5 +96,5 @@ export const NextBuildContext: Partial<{
isCompileMode
?:
boolean
debugPrerender
:
boolean
analyze
:
boolean
profiler
:
boolean
insights
:
boolean
}
>
=
{}
packages/next/src/build/define-env.ts
View file @
ad4f5ce5
...
...
@@ -345,7 +345,7 @@ export function getDefineEnv({
config
.
experimental
.
reactDebugChannel
??
false
,
'process.env.__NEXT_TRANSITION_INDICATOR'
:
config
.
experimental
.
transitionIndicator
??
false
,
'process.env.__NEXT_
PROFILER_BUILD'
:
config
.
profiler
??
false
,
'process.env.__NEXT_
INSIGHTS_BUILD'
:
config
.
insights
??
false
,
}
const
userDefines
=
config
.
compiler
?.
define
??
{}
...
...
packages/next/src/build/index.ts
View file @
ad4f5ce5
...
...
@@ -891,7 +891,7 @@ export default async function build(
traceUploadUrl
:
string
|
undefined
,
debugBuildAppPaths
?:
string
[],
debugBuildPagePaths
?:
string
[],
profiler
=
false
insights
=
false
):
Promise
<
void
>
{
const
isCompileMode
=
experimentalBuildMode
===
'compile'
const
isGenerateMode
=
experimentalBuildMode
===
'generate'
...
...
@@ -914,7 +914,7 @@ export default async function build(
NextBuildContext
.
reactProductionProfiling
=
reactProductionProfiling
NextBuildContext
.
noMangling
=
noMangling
NextBuildContext
.
debugPrerender
=
debugPrerender
NextBuildContext
.
profiler
=
profiler
NextBuildContext
.
insights
=
insights
await
nextBuildSpan
.
traceAsyncFn
(
async
()
=>
{
// attempt to load global env values so they are available in next.config.js
...
...
@@ -934,7 +934,7 @@ export default async function build(
silent
:
false
,
reactProductionProfiling
,
debugPrerender
,
profiler
,
insights
,
}),
turborepoAccessTraceResult
)
...
...
packages/next/src/build/turbopack-build/impl.ts
View file @
ad4f5ce5
...
...
@@ -230,7 +230,7 @@ export async function workerMain(workerData: {
{
debugPrerender
:
NextBuildContext
.
debugPrerender
,
reactProductionProfiling
:
NextBuildContext
.
reactProductionProfiling
,
profiler
:
NextBuildContext
.
profiler
,
insights
:
NextBuildContext
.
insights
,
}
))
// Matches handling in build/index.ts
...
...
packages/next/src/build/webpack-build/impl.ts
View file @
ad4f5ce5
...
...
@@ -390,7 +390,7 @@ export async function workerMain(workerData: {
{
debugPrerender
:
NextBuildContext
.
debugPrerender
,
reactProductionProfiling
:
NextBuildContext
.
reactProductionProfiling
,
profiler
:
NextBuildContext
.
profiler
,
insights
:
NextBuildContext
.
insights
,
}
))
await
installBindings
(
config
.
experimental
?.
useWasmBinary
)
...
...
packages/next/src/build/webpack-config.ts
View file @
ad4f5ce5
...
...
@@ -394,8 +394,8 @@ export default async function getBaseWebpackConfig(
const
hasAppDir
=
!!
appDir
const
disableOptimizedLoading
=
true
// Combine reactProductionProfiling with
profiler
flag for React profiling builds
const
enableReactProfiling
=
reactProductionProfiling
||
config
.
profiler
// Combine reactProductionProfiling with
insights
flag for React profiling builds
const
enableReactProfiling
=
reactProductionProfiling
||
config
.
insights
const
bundledReactChannel
=
needsExperimentalReact
(
config
)
?
'-experimental'
:
''
...
...
packages/next/src/cli/next-build.ts
View file @
ad4f5ce5
...
...
@@ -21,7 +21,7 @@ export type NextBuildOptions = {
debug
?:
boolean
debugPrerender
?:
boolean
profile
?:
boolean
profiler
?:
boolean
insights
?:
boolean
mangling
:
boolean
turbo
?:
boolean
turbopack
?:
boolean
...
...
@@ -45,7 +45,7 @@ const nextBuild = async (options: NextBuildOptions, directory?: string) => {
debugPrerender
,
experimentalDebugMemoryUsage
,
profile
,
profiler
,
insights
,
mangling
,
experimentalAppOnly
,
experimentalBuildMode
,
...
...
@@ -86,9 +86,9 @@ const nextBuild = async (options: NextBuildOptions, directory?: string) => {
)
}
if
(
profiler
)
{
if
(
insights
)
{
warn
(
`
Profiler
build is enabled.
${
italic
(
`
Insights
build is enabled.
${
italic
(
'Note: Source maps are enabled and minification is disabled. This build is not suitable for production.'
)}
`
)
...
...
@@ -139,7 +139,7 @@ const nextBuild = async (options: NextBuildOptions, directory?: string) => {
traceUploadUrl
,
resolvedAppPaths
,
resolvedPagePaths
,
profiler
insights
)
.
catch
((
err
)
=>
{
if
(
experimentalDebugMemoryUsage
)
{
...
...
packages/next/src/client/app-bootstrap.ts
View file @
ad4f5ce5
...
...
@@ -15,11 +15,11 @@ window.next = {
appDir
:
true
,
}
// Log
profiler
build info at startup
if
(
process
.
env
.
__NEXT_
PROFILER
_BUILD
)
{
// Log
insights
build info at startup
if
(
process
.
env
.
__NEXT_
INSIGHTS
_BUILD
)
{
console
.
log
(
''
)
console
.
log
(
'%c[Next.js
Profiler
Build]'
,
'%c[Next.js
Insights
Build]'
,
'background: #0070f3; color: white; padding: 2px 6px; border-radius: 3px;'
,
'
\
n• Source maps: enabled'
,
'
\
n• Minification: disabled'
,
...
...
packages/next/src/client/index.tsx
View file @
ad4f5ce5
...
...
@@ -50,11 +50,11 @@ import { isNextRouterError } from './components/is-next-router-error'
/// <reference types="react-dom/experimental" />
// Log
profiler
build info at startup
if
(
process
.
env
.
__NEXT_
PROFILER
_BUILD
)
{
// Log
insights
build info at startup
if
(
process
.
env
.
__NEXT_
INSIGHTS
_BUILD
)
{
console
.
log
(
''
)
console
.
log
(
'%c[Next.js
Profiler
Build]'
,
'%c[Next.js
Insights
Build]'
,
'background: #0070f3; color: white; padding: 2px 6px; border-radius: 3px;'
,
'
\
n• Source maps: enabled'
,
'
\
n• Minification: disabled'
,
...
...
packages/next/src/client/waterfall-detector.ts
View file @
ad4f5ce5
This diff is collapsed.
Click to expand it.
packages/next/src/lib/require-instrumentation-client.ts
View file @
ad4f5ce5
...
...
@@ -8,7 +8,7 @@
// Initialize waterfall detector FIRST (before any other code runs)
// This must happen before the instrumentation client is loaded to patch fetch early
let
disableWaterfallDetector
:
(()
=>
void
)
|
null
=
null
if
(
process
.
env
.
__NEXT_
PROFILER
_BUILD
)
{
if
(
process
.
env
.
__NEXT_
INSIGHTS
_BUILD
)
{
const
waterfallDetector
=
require
(
'../client/waterfall-detector'
)
as
typeof
import
(
'../client/waterfall-detector'
)
waterfallDetector
.
initWaterfallDetector
()
...
...
packages/next/src/server/config-shared.ts
View file @
ad4f5ce5
...
...
@@ -1141,11 +1141,11 @@ export interface NextConfig {
reactProductionProfiling
?:
boolean
/**
* Enable
profiler
build with source maps and no minification.
* This is set automatically when using `next build --
profiler
`.
* Enable
insights
build with source maps and no minification.
* This is set automatically when using `next build --
insights
`.
* @internal
*/
profiler
?:
boolean
insights
?:
boolean
/**
* The Next.js runtime is Strict Mode-compliant.
...
...
@@ -1429,7 +1429,7 @@ export const defaultConfig = Object.freeze({
productionBrowserSourceMaps
:
false
,
excludeDefaultMomentLocales
:
true
,
reactProductionProfiling
:
false
,
profiler
:
false
,
insights
:
false
,
reactStrictMode
:
null
,
reactMaxHeadersLength
:
6000
,
httpAgentOptions
:
{
...
...
@@ -1632,7 +1632,7 @@ export interface NextConfigRuntime {
skipProxyUrlNormalize
:
NextConfigComplete
[
'skipProxyUrlNormalize'
]
pageExtensions
:
NextConfigComplete
[
'pageExtensions'
]
useFileSystemPublicRoutes
:
NextConfigComplete
[
'useFileSystemPublicRoutes'
]
profiler
?:
NextConfigComplete
[
'profiler
'
]
insights
?:
NextConfigComplete
[
'insights
'
]
experimental
:
Pick
<
NextConfigComplete
[
'experimental'
],
...
...
@@ -1762,7 +1762,7 @@ export function getNextConfigRuntime(
skipProxyUrlNormalize
:
config
.
skipProxyUrlNormalize
,
pageExtensions
:
config
.
pageExtensions
,
useFileSystemPublicRoutes
:
config
.
useFileSystemPublicRoutes
,
profiler
:
config
.
profiler
,
insights
:
config
.
insights
,
experimental
,
}
...
...
packages/next/src/server/config.ts
View file @
ad4f5ce5
...
...
@@ -1415,7 +1415,7 @@ function getCacheKey(
customConfig
?:
object
|
null
,
reactProductionProfiling
?:
boolean
,
debugPrerender
?:
boolean
,
profiler
?:
boolean
,
insights
?:
boolean
,
pid
?:
number
):
string
{
// The next.config.js is unique per project, so we can use the dir as the major key
...
...
@@ -1426,7 +1426,7 @@ function getCacheKey(
hasCustomConfig
:
Boolean
(
customConfig
),
reactProductionProfiling
:
Boolean
(
reactProductionProfiling
),
debugPrerender
:
Boolean
(
debugPrerender
),
profiler
:
Boolean
(
profiler
),
insights
:
Boolean
(
insights
),
pid
:
pid
||
0
,
})
...
...
@@ -1442,7 +1442,7 @@ type LoadConfigOptions = {
)
=>
void
reactProductionProfiling
?:
boolean
debugPrerender
?:
boolean
profiler
?:
boolean
insights
?:
boolean
}
export
default
async
function
loadConfig
(
...
...
@@ -1471,7 +1471,7 @@ export default async function loadConfig(
reportExperimentalFeatures
,
reactProductionProfiling
,
debugPrerender
,
profiler
,
insights
,
}:
LoadConfigOptions
=
{}
):
Promise
<
NextConfigComplete
>
{
// Generate cache key based on parameters that affect config output
...
...
@@ -1482,7 +1482,7 @@ export default async function loadConfig(
customConfig
,
reactProductionProfiling
,
debugPrerender
,
profiler
,
insights
,
process
.
pid
)
...
...
@@ -1723,7 +1723,7 @@ export default async function loadConfig(
isDefaultConfig
:
false
,
configuredExperimentalFeatures
,
debugPrerender
,
profiler
,
insights
,
phase
,
})
...
...
@@ -1782,7 +1782,7 @@ export default async function loadConfig(
isDefaultConfig
:
true
,
configuredExperimentalFeatures
,
debugPrerender
,
profiler
,
insights
,
phase
,
})
...
...
@@ -1825,14 +1825,14 @@ function enforceExperimentalFeatures(
isDefaultConfig
:
boolean
configuredExperimentalFeatures
:
ConfiguredExperimentalFeature
[]
|
undefined
debugPrerender
:
boolean
|
undefined
profiler
:
boolean
|
undefined
insights
:
boolean
|
undefined
phase
:
PHASE_TYPE
}
)
{
const
{
configuredExperimentalFeatures
,
debugPrerender
,
profiler
,
insights
,
isDefaultConfig
,
phase
,
}
=
options
...
...
@@ -1868,9 +1868,9 @@ function enforceExperimentalFeatures(
)
}
//
Profiler
build: enable source maps (client + server) and disable minification
//
Insights
build: enable source maps (client + server) and disable minification
if
(
profiler
&&
insights
&&
(
phase
===
PHASE_PRODUCTION_BUILD
||
phase
===
PHASE_EXPORT
)
)
{
// Enable client-side source maps
...
...
@@ -1901,8 +1901,8 @@ function enforceExperimentalFeatures(
configuredExperimentalFeatures
)
// Mark this as a
profiler
build in config for runtime detection
config
.
profiler
=
true
// Mark this as a
insights
build in config for runtime detection
config
.
insights
=
true
}
// TODO: Remove this once we've made Cache Components the default.
...
...
packages/next/src/server/lib/app-info-log.ts
View file @
ad4f5ce5
...
...
@@ -16,6 +16,7 @@ export function logStartInfo({
experimentalFeatures
,
logBundler
,
cacheComponents
,
insights
,
}:
{
networkUrl
:
string
|
null
appUrl
:
string
|
null
...
...
@@ -23,6 +24,7 @@ export function logStartInfo({
experimentalFeatures
?:
ConfiguredExperimentalFeature
[]
logBundler
:
boolean
cacheComponents
?:
boolean
insights
?:
boolean
})
{
let
versionSuffix
=
''
const
parts
=
[]
...
...
@@ -41,6 +43,10 @@ export function logStartInfo({
parts
.
push
(
'Cache Components'
)
}
if
(
insights
)
{
parts
.
push
(
'Insights'
)
}
if
(
parts
.
length
>
0
)
{
versionSuffix
=
` (
${
parts
.
join
(
', '
)}
)`
}
...
...
@@ -114,9 +120,11 @@ export async function getStartServerInfo({
envInfo
?:
string
[]
experimentalFeatures
?:
ConfiguredExperimentalFeature
[]
cacheComponents
?:
boolean
insights
?:
boolean
}
>
{
let
experimentalFeatures
:
ConfiguredExperimentalFeature
[]
=
[]
let
cacheComponents
=
false
let
insights
=
false
const
config
=
await
loadConfig
(
dev
?
PHASE_DEVELOPMENT_SERVER
:
PHASE_PRODUCTION_BUILD
,
dir
,
...
...
@@ -132,6 +140,7 @@ export async function getStartServerInfo({
)
cacheComponents
=
!!
config
.
cacheComponents
insights
=
!!
config
.
insights
// we need to reset env if we are going to create
// the worker process with the esm loader so that the
...
...
@@ -146,5 +155,6 @@ export async function getStartServerInfo({
envInfo
,
experimentalFeatures
,
cacheComponents
,
insights
,
}
}
packages/next/src/server/lib/start-server.ts
View file @
ad4f5ce5
...
...
@@ -355,15 +355,22 @@ export async function startServer(
}
// Only load env and config in dev to for logging purposes
// For production, we still need to check for insights mode
let
envInfo
:
string
[]
|
undefined
let
experimentalFeatures
:
ConfiguredExperimentalFeature
[]
|
undefined
let
cacheComponents
:
boolean
|
undefined
let
insights
:
boolean
|
undefined
try
{
if
(
isDev
)
{
const
startServerInfo
=
await
getStartServerInfo
({
dir
,
dev
:
isDev
})
envInfo
=
startServerInfo
.
envInfo
cacheComponents
=
startServerInfo
.
cacheComponents
experimentalFeatures
=
startServerInfo
.
experimentalFeatures
insights
=
startServerInfo
.
insights
}
else
{
// For production, check if this is an insights build
const
startServerInfo
=
await
getStartServerInfo
({
dir
,
dev
:
false
})
insights
=
startServerInfo
.
insights
}
logStartInfo
({
networkUrl
,
...
...
@@ -371,6 +378,7 @@ export async function startServer(
envInfo
,
experimentalFeatures
,
cacheComponents
,
insights
,
logBundler
:
isDev
,
})
...
...
packages/next/src/server/next-server.ts
View file @
ad4f5ce5
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment