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
e3e435e2
Commit
e3e435e2
authored
Feb 08, 2026
by
Jimmy Lai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(cache): avoid pulling server internals into browser bundles
parent
d87bcc61
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
15 deletions
+46
-15
cache.js
packages/next/cache.js
+46
-15
No files found.
packages/next/cache.js
View file @
e3e435e2
const
cacheExports
=
{
let
cacheExports
unstable_cache
:
require
(
'next/dist/server/web/spec-extension/unstable-cache'
)
.
unstable_cache
,
updateTag
:
require
(
'next/dist/server/web/spec-extension/revalidate'
)
if
(
process
.
env
.
NEXT_RUNTIME
===
''
)
{
.
updateTag
,
const
notAvailableInClient
=
(
name
)
=>
{
return
function
notAvailable
()
{
throw
new
Error
(
`\`
${
name
}
\` is only available in a Server Component.`
)
}
}
cacheExports
=
{
unstable_cache
:
function
unstable_cache
(
cb
)
{
// Legacy behavior: allow importing/using unstable_cache from client bundles
// without pulling in server internals.
if
(
typeof
cb
!==
'function'
)
return
cb
return
function
cached
()
{
return
cb
.
apply
(
this
,
arguments
)
}
},
unstable_noStore
:
function
unstable_noStore
()
{},
updateTag
:
notAvailableInClient
(
'updateTag'
),
revalidateTag
:
notAvailableInClient
(
'revalidateTag'
),
revalidatePath
:
notAvailableInClient
(
'revalidatePath'
),
refresh
:
notAvailableInClient
(
'refresh'
),
cacheLife
:
notAvailableInClient
(
'cacheLife'
),
cacheTag
:
notAvailableInClient
(
'cacheTag'
),
}
}
else
{
// Keep server requires in this branch so browser builds can DCE them.
cacheExports
=
{
unstable_cache
:
require
(
'next/dist/server/web/spec-extension/unstable-cache'
)
.
unstable_cache
,
updateTag
:
require
(
'next/dist/server/web/spec-extension/revalidate'
)
.
updateTag
,
revalidateTag
:
require
(
'next/dist/server/web/spec-extension/revalidate'
)
revalidateTag
:
require
(
'next/dist/server/web/spec-extension/revalidate'
)
.
revalidateTag
,
.
revalidateTag
,
revalidatePath
:
require
(
'next/dist/server/web/spec-extension/revalidate'
)
revalidatePath
:
require
(
'next/dist/server/web/spec-extension/revalidate'
)
.
revalidatePath
,
.
revalidatePath
,
refresh
:
require
(
'next/dist/server/web/spec-extension/revalidate'
).
refresh
,
refresh
:
require
(
'next/dist/server/web/spec-extension/revalidate'
).
refresh
,
unstable_noStore
:
unstable_noStore
:
require
(
'next/dist/server/web/spec-extension/unstable-no-store'
)
require
(
'next/dist/server/web/spec-extension/unstable-no-store'
)
.
unstable_noStore
,
.
unstable_noStore
,
cacheLife
:
require
(
'next/dist/server/use-cache/cache-life'
).
cacheLife
,
cacheLife
:
require
(
'next/dist/server/use-cache/cache-life'
).
cacheLife
,
cacheTag
:
require
(
'next/dist/server/use-cache/cache-tag'
).
cacheTag
,
cacheTag
:
require
(
'next/dist/server/use-cache/cache-tag'
).
cacheTag
,
}
}
}
let
didWarnCacheLife
=
false
let
didWarnCacheLife
=
false
...
...
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