-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Differentiate error messages in server function transforms (#71491)
Updated error messages to differentiate between the two different directives. ### `"use server"` - `Server Actions must be async functions.` - `Only async functions are allowed to be exported in a "use server" file.` ### `"use cache"` - `"use cache" functions must be async functions.` - `Only async functions are allowed to be exported in a "use cache" file.`
- Loading branch information
1 parent
3de04dc
commit 8c401f6
Showing
15 changed files
with
139 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
crates/next-custom-transforms/tests/errors/server-actions/server-graph/14/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
'use cache' | ||
|
||
export default function () {} | ||
export function foo() {} | ||
export const bar = () => {} | ||
export const baz = 42 |
Empty file.
27 changes: 27 additions & 0 deletions
27
crates/next-custom-transforms/tests/errors/server-actions/server-graph/14/output.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
x "use cache" functions must be async functions. | ||
,-[input.js:3:1] | ||
2 | | ||
3 | export default function () {} | ||
: ^^^^^^^^^^^^^^ | ||
4 | export function foo() {} | ||
`---- | ||
x "use cache" functions must be async functions. | ||
,-[input.js:4:1] | ||
3 | export default function () {} | ||
4 | export function foo() {} | ||
: ^^^ | ||
5 | export const bar = () => {} | ||
`---- | ||
x "use cache" functions must be async functions. | ||
,-[input.js:5:1] | ||
4 | export function foo() {} | ||
5 | export const bar = () => {} | ||
: ^^^^^^^^ | ||
6 | export const baz = 42 | ||
`---- | ||
x Only async functions are allowed to be exported in a "use cache" file. | ||
,-[input.js:6:1] | ||
5 | export const bar = () => {} | ||
6 | export const baz = 42 | ||
: ^^^^^^^^^^^^^^^^^^^^^ | ||
`---- |
11 changes: 11 additions & 0 deletions
11
crates/next-custom-transforms/tests/errors/server-actions/server-graph/15/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export default function () { | ||
'use cache' | ||
} | ||
|
||
export function foo() { | ||
'use cache' | ||
} | ||
|
||
export const bar = () => { | ||
'use cache' | ||
} |
3 changes: 3 additions & 0 deletions
3
crates/next-custom-transforms/tests/errors/server-actions/server-graph/15/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function() {} | ||
export function foo() {} | ||
export const bar = ()=>{}; |
20 changes: 20 additions & 0 deletions
20
crates/next-custom-transforms/tests/errors/server-actions/server-graph/15/output.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
x "use cache" functions must be async functions. | ||
,-[input.js:1:1] | ||
1 | ,-> export default function () { | ||
2 | | 'use cache' | ||
3 | `-> } | ||
`---- | ||
x "use cache" functions must be async functions. | ||
,-[input.js:5:1] | ||
4 | | ||
5 | export function foo() { | ||
: ^^^ | ||
6 | 'use cache' | ||
`---- | ||
x "use cache" functions must be async functions. | ||
,-[input.js:9:1] | ||
8 | | ||
9 | ,-> export const bar = () => { | ||
10 | | 'use cache' | ||
11 | `-> } | ||
`---- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +0,0 @@ | ||
/* __next_internal_action_entry_do_not_use__ {"b78c261f135a7a852508c2920bd7228020ff4bd7":"x"} */ import { registerServerReference } from "private-next-rsc-server-reference"; | ||
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; | ||
export const x = 1; | ||
import { ensureServerEntryExports } from "private-next-rsc-action-validate"; | ||
ensureServerEntryExports([ | ||
x | ||
]); | ||
registerServerReference(x, "b78c261f135a7a852508c2920bd7228020ff4bd7", null); | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +0,0 @@ | ||
/* __next_internal_action_entry_do_not_use__ {} */ import { registerServerReference } from "private-next-rsc-server-reference"; | ||
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; | ||
export default class Component { | ||
render() { | ||
return null; | ||
} | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +0,0 @@ | ||
/* __next_internal_action_entry_do_not_use__ {} */ import { registerServerReference } from "private-next-rsc-server-reference"; | ||
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; | ||
export * from 'foo'; | ||
14 changes: 12 additions & 2 deletions
14
crates/next-custom-transforms/tests/errors/server-actions/server-graph/6/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
/* __next_internal_action_entry_do_not_use__ {} */ import { registerServerReference } from "private-next-rsc-server-reference"; | ||
/* __next_internal_action_entry_do_not_use__ {"c18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default"} */ import { registerServerReference } from "private-next-rsc-server-reference"; | ||
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; | ||
export default (()=>{}); | ||
export default $$RSC_SERVER_ACTION_0 = ()=>{}; | ||
var $$RSC_SERVER_ACTION_0; | ||
Object.defineProperty($$RSC_SERVER_ACTION_0, "name", { | ||
"value": "default", | ||
"writable": false | ||
}); | ||
import { ensureServerEntryExports } from "private-next-rsc-action-validate"; | ||
ensureServerEntryExports([ | ||
$$RSC_SERVER_ACTION_0 | ||
]); | ||
registerServerReference($$RSC_SERVER_ACTION_0, "c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null); |
4 changes: 2 additions & 2 deletions
4
crates/next-custom-transforms/tests/errors/server-actions/server-graph/6/output.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
x Only async functions are allowed to be exported in a "use server" file. | ||
x Server Actions must be async functions. | ||
,-[input.js:3:1] | ||
2 | | ||
3 | export default () => {} | ||
: ^^^^^^^^^^^^^^^^^^^^^^^ | ||
: ^^^^^^^^ | ||
`---- |
5 changes: 1 addition & 4 deletions
5
crates/next-custom-transforms/tests/errors/server-actions/server-graph/7/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1 @@ | ||
/* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; | ||
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; | ||
export const $$RSC_SERVER_ACTION_0 = async function foo() {}; | ||
const foo = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null); | ||
const foo = ()=>{}; |
2 changes: 1 addition & 1 deletion
2
crates/next-custom-transforms/tests/errors/server-actions/server-graph/7/output.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8c401f6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stats from current release
Default Build (Increase detected⚠️ )
General Overall increase⚠️
Client Bundles (main, webpack) Overall increase⚠️
Legacy Client Bundles (polyfills)
Client Pages
Client Build Manifests
Rendered Page Sizes
Edge SSR bundle Size Overall increase⚠️
Middleware size
Next Runtimes Overall increase⚠️
build cache
Diff details
Diff for page.js
Diff too large to display
Diff for middleware.js
Diff too large to display
Diff for edge-ssr.js
Diff too large to display
Diff for image-HASH.js
Diff for 1495-HASH.js
Diff for 9073-HASH.js
Diff too large to display
Diff for d4c1d954-HASH.js
Diff too large to display
Diff for main-HASH.js
Diff too large to display
Diff for app-page-exp..ntime.dev.js
Diff for app-page-exp..time.prod.js
Diff too large to display
Diff for app-page-tur..time.prod.js
Diff too large to display
Diff for app-page-tur..time.prod.js
Diff too large to display
Diff for app-page.runtime.dev.js
Diff for app-page.runtime.prod.js
Diff too large to display
Diff for app-route-ex..ntime.dev.js
Diff too large to display
Diff for app-route-ex..time.prod.js
Diff too large to display
Diff for app-route-tu..time.prod.js
Diff too large to display
Diff for app-route-tu..time.prod.js
Diff too large to display
Diff for app-route.runtime.dev.js
Diff too large to display
Diff for app-route.ru..time.prod.js
Diff too large to display
Diff for server.runtime.prod.js
Diff too large to display
8c401f6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stats from current release
Default Build (Increase detected⚠️ )
General Overall increase⚠️
Client Bundles (main, webpack) Overall increase⚠️
Legacy Client Bundles (polyfills)
Client Pages
Client Build Manifests
Rendered Page Sizes
Edge SSR bundle Size Overall increase⚠️
Middleware size
Next Runtimes Overall increase⚠️
build cache Overall increase⚠️
Diff details
Diff for page.js
Diff too large to display
Diff for middleware.js
Diff too large to display
Diff for edge-ssr.js
Diff too large to display
Diff for image-HASH.js
Diff for 1495-HASH.js
Diff for 9073-HASH.js
Diff too large to display
Diff for d4c1d954-HASH.js
Diff too large to display
Diff for main-HASH.js
Diff too large to display
Diff for app-page-exp..ntime.dev.js
Diff for app-page-exp..time.prod.js
Diff too large to display
Diff for app-page-tur..time.prod.js
Diff too large to display
Diff for app-page-tur..time.prod.js
Diff too large to display
Diff for app-page.runtime.dev.js
Diff for app-page.runtime.prod.js
Diff too large to display
Diff for app-route-ex..ntime.dev.js
Diff too large to display
Diff for app-route-ex..time.prod.js
Diff too large to display
Diff for app-route-tu..time.prod.js
Diff too large to display
Diff for app-route-tu..time.prod.js
Diff too large to display
Diff for app-route.runtime.dev.js
Diff too large to display
Diff for app-route.ru..time.prod.js
Diff too large to display
Diff for server.runtime.prod.js
Diff too large to display