gohugoio/hugo · error

unsupported jsx type

Error message

unsupported jsx type: %q

What it means

Thrown when the JSX option is not one of transform (default), preserve, or automatic. These map directly to esbuild's api.JSX values.

Solutions

  1. Use: transform (default), preserve, or automatic.
  2. If using automatic, also set JSXImportSource (e.g. react).

Example fix

// before
{{ $opts := dict "jsx" "classic" }}

// after
{{ $opts := dict "jsx" "automatic" "jsxImportSource" "react" }}
Defensive patterns

Strategy: validation

Validate before calling

switch opts.JSX {
case "", "transform", "preserve", "automatic":
    // ok
default:
    return fmt.Errorf("unsupported jsx type: %q", opts.JSX)
}

Prevention

When it happens

Trigger: Setting JSX to classic, react, or any other string.

Common situations: User assumes classic React behavior or uses Babel/TypeScript terminology like classic or react.

Related errors


AI-assisted analysis of gohugoio/hugo@52c9bd7908 (2026-08-09). Data as JSON: /api/errors/035bc5eb8d062d3d. Report an issue: GitHub.

Appendix: source

Thrown at internal/js/esbuild/options.go:370

	case "esm":
		format = api.FormatESModule
	case "cjs":
		format = api.FormatCommonJS
	default:
		err = fmt.Errorf("unsupported script output format: %q", opts.Format)
		return
	}

	var jsx api.JSX
	switch opts.JSX {
	case "", "transform":
		jsx = api.JSXTransform
	case "preserve":
		jsx = api.JSXPreserve
	case "automatic":
		jsx = api.JSXAutomatic
	default:
		err = fmt.Errorf("unsupported jsx type: %q", opts.JSX)
		return
	}

	var platform api.Platform
	switch opts.Platform {
	case "", "browser":
		platform = api.PlatformBrowser
	case "node":
		platform = api.PlatformNode
	case "neutral":
		platform = api.PlatformNeutral
	default:
		err = fmt.Errorf("unsupported platform type: %q", opts.Platform)
		return
	}

	var defines map[string]string
	if opts.Defines != nil {

View on GitHub (pinned to 52c9bd7908)