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

turbopack: Don't error with legacy server actions boolean #58416

Merged
merged 4 commits into from
Nov 15, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions packages/next-swc/crates/next-core/src/next_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ pub struct ExperimentalConfig {
pub optimize_css: Option<serde_json::Value>,
pub next_script_workers: Option<bool>,
pub web_vitals_attribution: Option<Vec<String>>,
pub server_actions: Option<ServerActions>,
pub server_actions: Option<ServerActionsOrLegacyBool>,
pub sri: Option<SubResourceIntegrity>,

// ---
Expand Down Expand Up @@ -511,7 +511,18 @@ pub struct SubResourceIntegrity {
pub algorithm: Option<String>,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, TraceRawVcs)]
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize, TraceRawVcs)]
#[serde(untagged)]
pub enum ServerActionsOrLegacyBool {
/// The current way to configure server actions sub behaviors.
ServerActionsConfig(ServerActions),

/// The legacy way to disable server actions. This is no longer used, server
/// actions is always enabled.
LegacyBool(bool),
}

#[derive(Clone, Debug, PartialEq, Deserialize, Serialize, TraceRawVcs)]
#[serde(rename_all = "camelCase")]
pub struct ServerActions {
/// Allows adjusting body parser size limit for server actions.
Expand Down
12 changes: 11 additions & 1 deletion packages/next/src/lib/turbopack-warning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,17 @@ export async function validateTurboNextConfig({
}

let isSupported =
supportedKeys.some((supportedKey) => key.startsWith(supportedKey)) ||
supportedKeys.some(
(supportedKey) =>
// Either the key matches (or is a more specific subkey) of
// supportedKey, or the key is the path to a specific subkey.
// | key | supportedKey |
// |---------|--------------|
// | foo | foo |
// | foo.bar | foo |
// | foo | foo.bar |
key.startsWith(supportedKey) || supportedKey.startsWith(`${key}.`)
) ||
getDeepValue(rawNextConfig, key) === getDeepValue(defaultConfig, key)
if (!isSupported) {
unsupportedConfig.push(key)
Expand Down
Loading