gohugoio/hugo · error

unsupported script output format

Error message

unsupported script output format: %q

What it means

Thrown when Format is not one of iife, esm, or cjs. These are the only output formats esbuild supports and Hugo exposes.

Solutions

  1. Use only: iife, esm, or cjs.

Example fix

// before
{{ $opts := dict "format" "commonjs" }}

// after
{{ $opts := dict "format" "cjs" }}
Defensive patterns

Strategy: validation

Validate before calling

switch opts.Format {
case "", "iife", "esm", "cjs":
    // ok
default:
    return fmt.Errorf("unsupported script output format: %q", opts.Format)
}

Prevention

When it happens

Trigger: Setting Format to umd, commonjs (wrong shorthand), module, etc.

Common situations: User assumes commonjs is the long form of cjs; tries umd or module; copy-paste from Webpack terminology.

Related errors


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

Appendix: source

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

		loader = api.LoaderJSX
	case media.Builtin.CSSType.SubType:
		loader = api.LoaderCSS
	default:
		err = fmt.Errorf("unsupported Media Type: %q", opts.MediaType)
		return
	}

	var format api.Format
	// One of: iife, cjs, esm
	switch opts.Format {
	case "", "iife":
		format = api.FormatIIFE
	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 {

View on GitHub (pinned to 52c9bd7908)