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
cba6144e
Unverified
Commit
cba6144e
authored
Feb 02, 2026
by
Hendrik Liebau
Committed by
GitHub
Feb 02, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[backport] Apply server actions transform to `node_modules` in route handlers (#89380)
Backports: - #89316
parent
3db90632
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
40 additions
and
21 deletions
+40
-21
context.rs
crates/next-core/src/next_server/context.rs
+2
-1
page.tsx
...2e/app-dir/use-cache/app/(partially-static)/[id]/page.tsx
+4
-10
route.ts
...pp-dir/use-cache/app/(partially-static)/api/[id]/route.ts
+15
-0
route.ts
...e2e/app-dir/use-cache/app/(partially-static)/api/route.ts
+3
-10
index.js
test/e2e/app-dir/use-cache/node_modules/my-pkg/index.js
+14
-0
use-cache.test.ts
test/e2e/app-dir/use-cache/use-cache.test.ts
+2
-0
No files found.
crates/next-core/src/next_server/context.rs
View file @
cba6144e
...
...
@@ -845,6 +845,7 @@ pub async fn get_server_module_options_context(
next_server_rules
.extend
(
common_next_server_rules
.iter
()
.cloned
());
internal_custom_rules
.extend
(
common_next_server_rules
);
foreign_next_server_rules
.extend
(
internal_custom_rules
.clone
());
let
module_options_context
=
ModuleOptionsContext
{
ecmascript
:
EcmascriptOptionsContext
{
...
...
@@ -854,7 +855,7 @@ pub async fn get_server_module_options_context(
..
module_options_context
};
let
foreign_code_module_options_context
=
ModuleOptionsContext
{
module_rules
:
internal_custom
_rules
.clone
(),
module_rules
:
foreign_next_server
_rules
.clone
(),
enable_webpack_loaders
:
foreign_enable_webpack_loaders
,
// NOTE(WEB-1016) PostCSS transforms should also apply to foreign code.
enable_postcss_transform
:
enable_foreign_postcss_transform
,
...
...
test/e2e/app-dir/use-cache/app/(partially-static)/[id]/page.tsx
View file @
cba6144e
import
{
cacheLife
}
from
'next/cache'
async
function
getCachedRandom
(
n
:
number
)
{
'use cache'
cacheLife
(
'weeks'
)
return
String
(
Math
.
ceil
(
Math
.
random
()
*
n
))
}
import
{
getCachedRandomWithCacheLife
}
from
'my-pkg'
export
async
function
generateStaticParams
()
{
return
[
{
id
:
`a
${
await
getCachedRandom
(
9
)}
`
},
{
id
:
`b
${
await
getCachedRandom
(
2
)}
`
},
{
id
:
`a
${
await
getCachedRandom
WithCacheLife
(
9
)}
`
},
{
id
:
`b
${
await
getCachedRandom
WithCacheLife
(
2
)}
`
},
]
}
export
default
async
function
Page
()
{
const
value
=
getCachedRandom
(
1
)
const
value
=
getCachedRandom
WithCacheLife
(
1
)
return
<
p
>
{
value
}
</
p
>
}
test/e2e/app-dir/use-cache/app/(partially-static)/api/[id]/route.ts
0 → 100644
View file @
cba6144e
import
{
getCachedRandomWithCacheLife
}
from
'my-pkg'
import
{
NextRequest
}
from
'next/server'
export
async
function
generateStaticParams
()
{
return
[{
id
:
await
getCachedRandomWithCacheLife
()
}]
}
export
async
function
GET
(
req
:
NextRequest
,
{
params
}:
{
params
:
Promise
<
{
id
:
string
}
>
}
)
{
const
{
id
}
=
await
params
return
Response
.
json
({
id
})
}
test/e2e/app-dir/use-cache/app/(partially-static)/api/route.ts
View file @
cba6144e
import
{
cacheTag
}
from
'next/cache'
async
function
getCachedRandom
()
{
'use cache'
cacheTag
(
'api'
)
return
Math
.
random
()
}
import
{
getCachedRandomWithTag
}
from
'my-pkg'
export
async
function
GET
()
{
const
rand1
=
await
getCachedRandom
(
)
const
rand2
=
await
getCachedRandom
(
)
const
rand1
=
await
getCachedRandom
WithTag
(
'api'
)
const
rand2
=
await
getCachedRandom
WithTag
(
'api'
)
return
Response
.
json
({
rand1
,
rand2
})
}
test/e2e/app-dir/use-cache/node_modules/my-pkg/index.js
View file @
cba6144e
import
{
cacheLife
,
cacheTag
}
from
'next/cache'
export
async
function
getCachedRandom
()
{
'use cache'
return
Math
.
random
()
}
export
async
function
getCachedRandomWithTag
(
tag
)
{
'use cache'
cacheTag
(
tag
)
return
Math
.
random
()
}
export
async
function
getCachedRandomWithCacheLife
(
n
=
1
)
{
'use cache'
cacheLife
(
'weeks'
)
return
String
(
Math
.
ceil
(
Math
.
random
()
*
n
))
}
export
async
function
getCachedRandomWithHandler
()
{
'use cache: default'
return
Math
.
random
()
...
...
test/e2e/app-dir/use-cache/use-cache.test.ts
View file @
cba6144e
...
...
@@ -474,6 +474,8 @@ describe('use-cache', () => {
// [id] route, first entry in generateStaticParams
expect
.
stringMatching
(
/
\/
a
\d
/
),
withCacheComponents
&&
'/api'
,
// api/[id] route handler using generateStaticParams with 'use cache' from node_modules
expect
.
stringMatching
(
/
\/
api
\/\d
/
),
// [id] route, second entry in generateStaticParams
expect
.
stringMatching
(
/
\/
b
\d
/
),
'/cache-fetch'
,
...
...
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