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
6bc2550c
Commit
6bc2550c
authored
Sep 18, 2025
by
Tim Neutkens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Development: Don't block on TypeScript validation
parent
e5afc390
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
60 deletions
+67
-60
setup-dev-bundler.ts
...ges/next/src/server/lib/router-utils/setup-dev-bundler.ts
+67
-60
No files found.
packages/next/src/server/lib/router-utils/setup-dev-bundler.ts
View file @
6bc2550c
...
@@ -344,7 +344,7 @@ async function startWatcher(
...
@@ -344,7 +344,7 @@ async function startWatcher(
},
},
})
})
const
fileWatchTimes
=
new
Map
()
const
fileWatchTimes
=
new
Map
()
let
enabledTypeScript
=
await
verifyTypeScript
(
opts
)
let
enabledTypeScript
:
Promise
<
boolean
>
=
verifyTypeScript
(
opts
)
let
previousClientRouterFilters
:
any
let
previousClientRouterFilters
:
any
let
previousConflictingPagePaths
:
Set
<
string
>
=
new
Set
()
let
previousConflictingPagePaths
:
Set
<
string
>
=
new
Set
()
...
@@ -411,7 +411,7 @@ async function startWatcher(
...
@@ -411,7 +411,7 @@ async function startWatcher(
if
(
tsconfigPaths
.
includes
(
fileName
))
{
if
(
tsconfigPaths
.
includes
(
fileName
))
{
if
(
fileName
.
endsWith
(
'tsconfig.json'
))
{
if
(
fileName
.
endsWith
(
'tsconfig.json'
))
{
enabledTypeScript
=
true
enabledTypeScript
=
Promise
.
resolve
(
true
)
}
}
if
(
watchTimeChange
)
{
if
(
watchTimeChange
)
{
tsconfigChange
=
true
tsconfigChange
=
true
...
@@ -487,7 +487,7 @@ async function startWatcher(
...
@@ -487,7 +487,7 @@ async function startWatcher(
}
}
if
(
fileName
.
endsWith
(
'.ts'
)
||
fileName
.
endsWith
(
'.tsx'
))
{
if
(
fileName
.
endsWith
(
'.ts'
)
||
fileName
.
endsWith
(
'.tsx'
))
{
enabledTypeScript
=
true
enabledTypeScript
=
Promise
.
resolve
(
true
)
}
}
if
(
!
(
isAppPath
||
isPagePath
))
{
if
(
!
(
isAppPath
||
isPagePath
))
{
...
@@ -1054,69 +1054,76 @@ async function startWatcher(
...
@@ -1054,69 +1054,76 @@ async function startWatcher(
}
}
prevSortedRoutes
=
sortedRoutes
prevSortedRoutes
=
sortedRoutes
if
(
enabledTypeScript
)
{
enabledTypeScript
// Using === false to make the check clearer.
.
then
(
async
(
enabled
)
=>
{
if
(
typescriptStatusFromLastAggregation
===
false
)
{
if
(
!
enabled
)
{
// we tolerate the error here as this is best effort
return
// and the manual install command will be shown
}
await
verifyTypeScript
(
opts
)
// Using === false to make the check clearer.
.
then
(()
=>
{
if
((
await
typescriptStatusFromLastAggregation
)
===
false
)
{
tsconfigChange
=
true
// we tolerate the error here as this is best effort
// and the manual install command will be shown
await
verifyTypeScript
(
opts
)
.
then
(()
=>
{
tsconfigChange
=
true
})
.
catch
(()
=>
{})
}
if
(
writeEnvDefinitions
&&
nextConfig
.
experimental
?.
typedEnv
)
{
// TODO: The call to propagateServerField 'loadEnvConfig' causes the env to be loaded twice on env file changes.
const
loadEnvConfig
=
(
require
(
'@next/env'
)
as
typeof
import
(
'@next/env'
)
).
loadEnvConfig
const
{
loadedEnvFiles
}
=
loadEnvConfig
(
dir
,
process
.
env
.
NODE_ENV
===
'development'
,
// Silent as it's the second time `loadEnvConfig` is called in this pass.
undefined
,
true
)
const
createEnvDefinitions
=
(
require
(
'../experimental/create-env-definitions'
)
as
typeof
import
(
'../experimental/create-env-definitions'
)
).
createEnvDefinitions
await
createEnvDefinitions
({
distDir
,
loadedEnvFiles
:
[
...
loadedEnvFiles
,
{
path
:
nextConfig
.
configFileName
,
env
:
nextConfig
.
env
,
contents
:
''
,
},
],
})
})
.
catch
(()
=>
{})
}
}
if
(
writeEnvDefinitions
&&
nextConfig
.
experimental
?.
typedEnv
)
{
const
routeTypesManifest
=
await
createRouteTypesManifest
({
// TODO: The call to propagateServerField 'loadEnvConfig' causes the env to be loaded twice on env file changes.
const
loadEnvConfig
=
(
require
(
'@next/env'
)
as
typeof
import
(
'@next/env'
)
).
loadEnvConfig
const
{
loadedEnvFiles
}
=
loadEnvConfig
(
dir
,
dir
,
process
.
env
.
NODE_ENV
===
'development'
,
pageRoutes
,
// Silent as it's the second time `loadEnvConfig` is called in this pass.
appRoutes
,
undefined
,
layoutRoutes
,
true
slots
,
)
redirects
:
opts
.
nextConfig
.
redirects
,
rewrites
:
opts
.
nextConfig
.
rewrites
,
const
createEnvDefinitions
=
(
// Ensure relative paths in validator.ts are computed from validatorFilePath,
require
(
'../experimental/create-env-definitions'
)
as
typeof
import
(
'../experimental/create-env-definitions'
)
// matching behavior of build and CLI typegen.
).
createEnvDefinitions
validatorFilePath
,
await
createEnvDefinitions
({
appRouteHandlers
,
distDir
,
pageApiRoutes
,
loadedEnvFiles
:
[
...
loadedEnvFiles
,
{
path
:
nextConfig
.
configFileName
,
env
:
nextConfig
.
env
,
contents
:
''
,
},
],
})
})
}
const
routeTypesManifest
=
await
createRouteTypesManifest
({
await
writeRouteTypesManifest
(
dir
,
routeTypesManifest
,
pageRoutes
,
routeTypesFilePath
,
appRoutes
,
opts
.
nextConfig
layoutRoutes
,
)
slots
,
await
writeValidatorFile
(
routeTypesManifest
,
validatorFilePath
)
redirects
:
opts
.
nextConfig
.
redirects
,
})
rewrites
:
opts
.
nextConfig
.
rewrites
,
.
catch
((
err
)
=>
{
// Ensure relative paths in validator.ts are computed from validatorFilePath,
Log
.
warn
(
'Failed to create TypeScript setup'
,
err
)
// matching behavior of build and CLI typegen.
validatorFilePath
,
appRouteHandlers
,
pageApiRoutes
,
})
})
await
writeRouteTypesManifest
(
routeTypesManifest
,
routeTypesFilePath
,
opts
.
nextConfig
)
await
writeValidatorFile
(
routeTypesManifest
,
validatorFilePath
)
}
if
(
!
resolved
)
{
if
(
!
resolved
)
{
resolve
()
resolve
()
...
...
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