Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow export decl with any init value in the actions compiler #49600

Merged
merged 5 commits into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 3 additions & 7 deletions packages/next-swc/crates/core/src/server_actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -717,13 +717,9 @@ impl<C: Comments> VisitMut for ServerActions<C> {

for decl in &mut var.decls {
if let Some(init) = &decl.init {
match &**init {
Expr::Fn(_f) => {}
Expr::Arrow(_a) => {}
Expr::Call(_c) => {}
_ => {
disallowed_export_span = *span;
}
if let Expr::Lit(_) = &**init {
// It's not allowed to export any literal.
disallowed_export_span = *span;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use server'

export const { sampleFunction } = someObject
export const { sampleFunction2 } = fn()
export let { 0: sampleFunction3, 1: sampleFunction4 } = [g(), g()]
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* __next_internal_action_entry_do_not_use__ sampleFunction,sampleFunction2,sampleFunction3,sampleFunction4 */ import __create_action_proxy__ from "private-next-rsc-action-proxy";
import createServerReference from "private-next-rsc-action-client-wrapper";
export const sampleFunction = createServerReference("bd336abe00c3c59da66acb696fc8e151d8e54ea4");
export const sampleFunction2 = createServerReference("a0c73dd6f5af839e3335c6b19262ecb86cca6af4");
export const sampleFunction3 = createServerReference("d4f2e95bc745b6500b439c0847003511748c8ece");
export const sampleFunction4 = createServerReference("f03b256ee88a51700367acee3082894e25e6e7d9");