-
Notifications
You must be signed in to change notification settings - Fork 27.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support re-exporting unnamed function expression (#46936)
Add support for cases like: ```js const foo = async function () {} export default foo const bar = async function() {} export { bar } ``` Also fix a bug where nested async function declarations are mistakenly counted as actions. Fixes NEXT-800.
- Loading branch information
Showing
7 changed files
with
126 additions
and
34 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
5 changes: 1 addition & 4 deletions
5
packages/next-swc/crates/core/tests/errors/server-actions/1/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__ foo */ export function foo() {} | ||
foo.$$typeof = Symbol.for("react.server.reference"); | ||
foo.$$id = "ab21efdafbe611287bc25c0462b1e0510d13e48b"; | ||
foo.$$bound = []; | ||
/* __next_internal_action_entry_do_not_use__ */ export function foo() {} |
7 changes: 2 additions & 5 deletions
7
packages/next-swc/crates/core/tests/errors/server-actions/2/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,5 +1,2 @@ | ||
/* __next_internal_action_entry_do_not_use__ bar */ 'use strict'; | ||
export function bar() {} | ||
bar.$$typeof = Symbol.for("react.server.reference"); | ||
bar.$$id = "ac840dcaf5e8197cb02b7f3a43c119b7a770b272"; | ||
bar.$$bound = []; | ||
/* __next_internal_action_entry_do_not_use__ */ 'use strict'; | ||
export function bar() {} |
7 changes: 7 additions & 0 deletions
7
packages/next-swc/crates/core/tests/fixture/server-actions/13/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,7 @@ | ||
'use server' | ||
|
||
const foo = async function () {} | ||
export default foo | ||
|
||
const bar = async function() {} | ||
export { bar } |
10 changes: 10 additions & 0 deletions
10
packages/next-swc/crates/core/tests/fixture/server-actions/13/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,10 @@ | ||
/* __next_internal_action_entry_do_not_use__ default,$ACTION_fn_1 */ const foo = async function $ACTION_fn_0() {}; | ||
$ACTION_fn_0.$$typeof = Symbol.for("react.server.reference"); | ||
$ACTION_fn_0.$$id = "c18c215a6b7cdc64bf709f3a714ffdef1bf9651d"; | ||
$ACTION_fn_0.$$bound = []; | ||
export default foo; | ||
const bar = async function $ACTION_fn_1() {}; | ||
$ACTION_fn_1.$$typeof = Symbol.for("react.server.reference"); | ||
$ACTION_fn_1.$$id = "5bde18329eb1c98fc2d6dea0a22639861a18ce65"; | ||
$ACTION_fn_1.$$bound = []; | ||
export { bar }; |
5 changes: 5 additions & 0 deletions
5
packages/next-swc/crates/core/tests/fixture/server-actions/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,5 @@ | ||
'use server' | ||
|
||
export async function foo() { | ||
async function bar() {} | ||
} |
6 changes: 6 additions & 0 deletions
6
packages/next-swc/crates/core/tests/fixture/server-actions/14/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,6 @@ | ||
/* __next_internal_action_entry_do_not_use__ foo */ export async function foo() { | ||
async function bar() {} | ||
} | ||
foo.$$typeof = Symbol.for("react.server.reference"); | ||
foo.$$id = "ab21efdafbe611287bc25c0462b1e0510d13e48b"; | ||
foo.$$bound = []; |