rsnext/packages
Shu Ding 922b5de06f
Support passing both closure arguments and parameters (#47212)
When calling the server (via `callServer`), we concat all closure values
(`$$bound`) and arguments of the function call into one array on the
client. Hence on the server, we will have to compile the function
differently to support that.

With this change, the compiled function will have a `$$with_bound` flag
to indicate that if it accepts closure values. If so, the only argument
passed will be an array like `[...bound_values, ...fn_args]`, and we
compile the function parameters to `(closure, arg1 = closure[N], arg2 =
closure[N + 1], ...)` where `N` is the number of the closure
identifiers. This way we can still fill these arguments by only pass an
"bound + args" array. If it doesn't accept closure values, it will be
directly called with `...fn_args` so no compilation change needed.

The reason that we use `arg1 = closure[N]` is that this can support
complex patterns in parameters such as `f(closure, {a} = closure[1], [b]
= closure[2])`.

fix NEXT-487 ([link](https://linear.app/vercel/issue/NEXT-487))
2023-03-16 19:11:13 -07:00
..
create-next-app v13.2.5-canary.5 2023-03-16 21:53:59 +01:00
eslint-config-next v13.2.5-canary.5 2023-03-16 21:53:59 +01:00
eslint-plugin-next v13.2.5-canary.5 2023-03-16 21:53:59 +01:00
font v13.2.5-canary.5 2023-03-16 21:53:59 +01:00
next Support passing both closure arguments and parameters (#47212) 2023-03-16 19:11:13 -07:00
next-bundle-analyzer v13.2.5-canary.5 2023-03-16 21:53:59 +01:00
next-codemod v13.2.5-canary.5 2023-03-16 21:53:59 +01:00
next-env v13.2.5-canary.5 2023-03-16 21:53:59 +01:00
next-mdx v13.2.5-canary.5 2023-03-16 21:53:59 +01:00
next-plugin-storybook v13.2.5-canary.5 2023-03-16 21:53:59 +01:00
next-polyfill-module v13.2.5-canary.5 2023-03-16 21:53:59 +01:00
next-polyfill-nomodule v13.2.5-canary.5 2023-03-16 21:53:59 +01:00
next-swc Support passing both closure arguments and parameters (#47212) 2023-03-16 19:11:13 -07:00
react-dev-overlay v13.2.5-canary.5 2023-03-16 21:53:59 +01:00
react-refresh-utils v13.2.5-canary.5 2023-03-16 21:53:59 +01:00