-
Notifications
You must be signed in to change notification settings - Fork 0
feat(compiler): remove action render mode #680
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -165,7 +165,11 @@ func parseConfigLiteral(expression ast.Expr, imports map[string]string) (gowdk.C | |
| needsExecutableLoad = true | ||
| continue | ||
| } | ||
| config.Render = parseRenderConfig(field.Value) | ||
| render, err := parseRenderConfig(field.Value) | ||
| if err != nil { | ||
| return gowdk.Config{}, false, false, err | ||
| } | ||
| config.Render = render | ||
| case "I18N": | ||
| if needsConfigExpressionEvaluation(field.Value) { | ||
| needsExecutableLoad = true | ||
|
|
@@ -352,19 +356,23 @@ func parseModuleConfig(expression ast.Expr) gowdk.ModuleConfig { | |
| return module | ||
| } | ||
|
|
||
| func parseRenderConfig(expression ast.Expr) gowdk.RenderConfig { | ||
| func parseRenderConfig(expression ast.Expr) (gowdk.RenderConfig, error) { | ||
| fields, ok := configLiteralFields(expression) | ||
| if !ok { | ||
| return gowdk.RenderConfig{} | ||
| return gowdk.RenderConfig{}, nil | ||
| } | ||
|
|
||
| var render gowdk.RenderConfig | ||
| for _, field := range fields { | ||
| if field.Name == "Default" { | ||
| render.Default = parseRenderMode(field.Value) | ||
| mode, err := parseRenderMode(field.Value) | ||
| if err != nil { | ||
| return gowdk.RenderConfig{}, err | ||
| } | ||
| render.Default = mode | ||
| } | ||
| } | ||
| return render | ||
| return render, nil | ||
| } | ||
|
|
||
| func parseI18NConfig(expression ast.Expr) gowdk.I18NConfig { | ||
|
|
@@ -425,36 +433,34 @@ func parseLocaleConfig(expression ast.Expr) (gowdk.LocaleConfig, bool) { | |
| return locale, true | ||
| } | ||
|
|
||
| func parseRenderMode(expression ast.Expr) gowdk.RenderMode { | ||
| func parseRenderMode(expression ast.Expr) (gowdk.RenderMode, error) { | ||
| if value := parseString(expression); value != "" { | ||
| mode, err := gowdk.ParseRenderMode(value) | ||
| if err == nil { | ||
| return mode | ||
| return mode, nil | ||
| } | ||
| return "" | ||
| return "", err | ||
| } | ||
| switch typed := expression.(type) { | ||
| case *ast.SelectorExpr: | ||
| return renderModeByName(typed.Sel.Name) | ||
| case *ast.Ident: | ||
| return renderModeByName(typed.Name) | ||
| default: | ||
| return "" | ||
| return "", fmt.Errorf("unsupported render mode expression") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
A literal config that explicitly leaves the render default at its zero value, e.g. Useful? React with 👍 / 👎. |
||
| } | ||
| } | ||
|
|
||
| func renderModeByName(name string) gowdk.RenderMode { | ||
| func renderModeByName(name string) (gowdk.RenderMode, error) { | ||
| switch name { | ||
| case "SPA": | ||
| return gowdk.SPA | ||
| case "Action": | ||
| return gowdk.Action | ||
| return gowdk.SPA, nil | ||
| case "Hybrid": | ||
| return gowdk.Hybrid | ||
| return gowdk.Hybrid, nil | ||
| case "SSR": | ||
| return gowdk.SSR | ||
| return gowdk.SSR, nil | ||
| default: | ||
| return "" | ||
| return "", fmt.Errorf("unknown render mode %q", name) | ||
| } | ||
| } | ||
|
|
||
|
|
||
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.
This new rejection only runs for the AST-only config path; when
Render.Defaultcontains an expression such asDefault: gowdk.RenderMode("action")or a variable initialized to that value,needsConfigExpressionEvaluationswitches toloadExecutableConfig, andvalidateLoadedConfignever revalidatesconfig.Render.Default. Those configs still load with the removed"action"mode and then fail later or produce inconsistent route metadata, despite this change intending removed render modes to fail during config loading.Useful? React with 👍 / 👎.