Commit Graph

2 Commits

Author SHA1 Message Date
Hendrik Liebau bb41cbd6ee Apply server actions transform to node_modules in route handlers (#89316)
The server actions transform, which handles the `'use cache'` directive,
was not being applied to `node_modules` when imported from route
handlers. This caused `'use cache'` functions from dependencies to fail
with errors like `"cacheLife() can only be called inside a 'use cache'
function"``.

The issue was that the `AppRoute` context used `internal_custom_rules`
for its foreign code module options, which did not include the server
actions transform. This is inconsistent with `AppRSC` (App Router
pages), which correctly uses `foreign_next_server_rules` that includes
the transform.

The fix extends `foreign_next_server_rules` with `internal_custom_rules`
and uses it for the foreign code context in `AppRoute`, matching the
pattern used by `AppRSC`.
2026-01-31 00:03:29 +01:00
Janka Uryga a598b5ba38 fix: make webpack handle "use cache" in node_modules (#78606)
Turbopack applies the "use cache" transform in node_modules, but Webpack
wasn't doing that. This is due to a sneaky little regex that controls
whether files in node_modules are passed to SWC for transforming or not
-- `use client` and `use server` were included there, but `use cache`
wasn't. This PR fixes that.

(I don't really expect NPM packages to use `"use cache"` because it's
pretty application-specific, but it might be relevant in a monorepo
situation where shared utils that use the directive can live in a
separate package)

---------

Co-authored-by: Hendrik Liebau <mail@hendrik-liebau.de>
2025-04-28 15:31:31 +00:00