9471fb854f
Currently to make inline-defined Server Actions work, the compiler hoists the actual `"use server"` function to the module level and convert the inlined function to a parentheses expression that creates a noop wrapper function and wraps it with the proxy. This works fine however expressions are still different from declarations (#57392). So there're some details that can't be aligned well. With this change, we're going to make the compilation for the two types of inline-defined Server Actions more robust and more lightweight: #### 1. Expressions ```jsx const action = async () => { "use server" ... } const action = async function () { "use server" ... } const action = async function named () { "use server" ... } foo={async function () { "use server" ... }} ... ``` These expressions can directly be replaced with a new expression `createActionProxy("id", hoisted_action)`. A `.bind(...)` member call can be followed if it needs to bind any variables from the closure level. #### 2. Declarations ```js async function named () { "use server" ... } ``` In this case, we replace all the same `named` idents to be the expression `createActionProxy("id", hoisted_action)`, and removed that function declaration. With these changes, these will be fewer structural changes to the AST and the code is more performant. The PR also changes it to use React's `registerServerReference` method directly instead of our in-house implementation inside `createActionProxy`. Another small change is to stabilize the comment header to use `BTreeMap` inside the SWC transform. Otherwise the test snapshots will randomly mismatch. Closes #57392. |
||
---|---|---|
.cargo | ||
.config | ||
.devcontainer | ||
.github | ||
.husky | ||
.vscode | ||
bench | ||
contributing | ||
docs | ||
errors | ||
examples | ||
packages | ||
scripts | ||
test | ||
turbo/generators | ||
.alexignore | ||
.alexrc | ||
.eslintignore | ||
.eslintrc.json | ||
.gitattributes | ||
.gitignore | ||
.node-version | ||
.npmrc | ||
.prettierignore | ||
.prettierignore_staged | ||
.prettierrc.json | ||
.rustfmt.toml | ||
azure-pipelines.yml | ||
Cargo.lock | ||
Cargo.toml | ||
CODE_OF_CONDUCT.md | ||
contributing.md | ||
jest.config.js | ||
jest.replay.config.js | ||
lerna.json | ||
license.md | ||
lint-staged.config.js | ||
package.json | ||
pnpm-lock.yaml | ||
pnpm-workspace.yaml | ||
readme.md | ||
release.js | ||
run-tests.js | ||
rust-toolchain | ||
socket.yaml | ||
test-file.txt | ||
tsconfig-tsec.json | ||
tsconfig.json | ||
tsec-exemptions.json | ||
turbo.json | ||
UPGRADING.md | ||
vercel.json |
Next.js
Getting Started
Visit https://nextjs.org/learn to get started with Next.js.
Documentation
Visit https://nextjs.org/docs to view the full documentation.
Who is using Next.js?
Next.js is used by the world's leading companies. Check out the Next.js Showcase to learn more.
Community
The Next.js community can be found on GitHub Discussions, where you can ask questions, voice ideas, and share your projects.
To chat with other community members you can join the Next.js Discord.
Our Code of Conduct applies to all Next.js community channels.
Contributing
Please see our contributing.md.
Good First Issues
We have a list of good first issues that contain bugs that have a relatively limited scope. This is a great place to get started, gain experience, and get familiar with our contribution process.
Authors
- Tim Neutkens (@timneutkens)
- Naoyuki Kanezawa (@nkzawa)
- Guillermo Rauch (@rauchg)
- Arunoda Susiripala (@arunoda)
- Tony Kovanen (@tonykovanen)
- Dan Zajdband (@impronunciable)
Security
If you believe you have found a security vulnerability in Next.js, we encourage you to responsibly disclose this and not open a public issue. We will investigate all legitimate reports. Email security@vercel.com
to disclose any security vulnerabilities.