Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions crates/next-custom-transforms/src/transforms/server_actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1895,18 +1895,17 @@ impl<C: Comments> VisitMut for ServerActions<C> {
Decl::Var(var) => {
let mut has_export_needing_wrapper = false;

// Validate exports and check for cache runtime wrappers. Disallow
// exporting literals, objects, and arrays directly (destructuring
// patterns are allowed since we can't statically know if the
// destructured value is a function).
for decl in &var.decls {
if let Pat::Ident(_) = &decl.name {
if let Some(init) = &decl.init {
match &**init {
Expr::Lit(_) | Expr::Object(_) | Expr::Array(_) => {
disallowed_export_span = *span;
}
_ => {}
// Disallow exporting literals. Admittedly, this is
// pretty arbitrary. We don't disallow exporting object
// and array literals, as that would be too restrictive,
// especially for page and layout files with
// 'use cache', that may want to export metadata or
// viewport objects.
if let Expr::Lit(_) = &**init {
disallowed_export_span = *span;
}
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async function a() {
}
}

export const { foo } = {
export const obj = {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted this test fixture to what it was before #86014. We have a dedicated fixture for destructuring at crates/next-custom-transforms/tests/fixture/server-actions/server-graph/56.

foo() {
return 42
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/* __next_internal_action_entry_do_not_use__ {"ffab21efdafbe611287bc25c0462b1e0510d13e48b":"foo"} */ import { registerServerReference } from "private-next-rsc-server-reference";
import { cache as $$cache__ } from "private-next-rsc-cache-wrapper";
import { cache as $$reactCache__ } from "react";
// not exported!
async function a() {
// this is allowed here
Expand All @@ -14,7 +11,7 @@ async function a() {
console.log(arguments);
};
}
const { foo } = {
export const obj = {
foo () {
return 42;
},
Expand All @@ -25,14 +22,3 @@ const { foo } = {
console.log(arguments);
}
};
let $$RSC_SERVER_CACHE_foo = foo;
if (typeof foo === "function") {
$$RSC_SERVER_CACHE_foo = $$reactCache__(function() {
return $$cache__("default", "ffab21efdafbe611287bc25c0462b1e0510d13e48b", 0, foo, arguments);
});
registerServerReference($$RSC_SERVER_CACHE_foo, "ffab21efdafbe611287bc25c0462b1e0510d13e48b", null);
Object["defineProperty"]($$RSC_SERVER_CACHE_foo, "name", {
value: "foo"
});
}
export { $$RSC_SERVER_CACHE_foo as foo };

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use cache'

// Should not get cache runtime wrappers.
export const foo = {},
bar = [1]
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use cache'

// Should not get cache runtime wrappers.
export const foo = {},
bar = [1]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Should not get cache runtime wrappers.
export const foo = {}, bar = [
1
];
Loading