{"record":{"id":"4ff9a5e738cd9740","repo":"gohugoio/hugo","slug":"only-esm-format-is-currently-supported","errorCode":null,"errorMessage":"only esm format is currently supported","messagePattern":"only esm format is currently supported","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/esbuild/batch.go","lineNumber":527,"sourceCode":"\t\t}\n\n\t\tstate.importerImportContext.Set(s, importContext{\n\t\t\tname:           s,\n\t\t\tresourceGetter: nil,\n\t\t\tdm:             g.dependencyManager,\n\t\t})\n\n\t\taddResource(g.id, s, r, true)\n\t}\n\n\tmediaTypes := b.client.d.ResourceSpec.MediaTypes()\n\n\texternalOptions := b.configOptions.Compiled().Options\n\tif externalOptions.Format == \"\" {\n\t\texternalOptions.Format = \"esm\"\n\t}\n\tif externalOptions.Format != \"esm\" {\n\t\treturn nil, fmt.Errorf(\"only esm format is currently supported\")\n\t}\n\n\tjsOpts := Options{\n\t\tExternalOptions: externalOptions,\n\t\tInternalOptions: InternalOptions{\n\t\t\tDependencyManager: b.dependencyManager,\n\t\t\tSplitting:         true,\n\t\t\tImportOnResolveFunc: func(imp string, args api.OnResolveArgs) string {\n\t\t\t\tvar importContextPath string\n\t\t\t\tif args.Kind == api.ResolveEntryPoint {\n\t\t\t\t\timportContextPath = args.Path\n\t\t\t\t} else {\n\t\t\t\t\timportContextPath = args.Importer\n\t\t\t\t}\n\t\t\t\timportContext, importContextFound := state.importerImportContext.Get(importContextPath)\n\n\t\t\t\t// We want to track the dependencies closest to where they're used.\n\t\t\t\tdm := b.dependencyManager","sourceCodeStart":509,"sourceCodeEnd":545,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/internal/js/esbuild/batch.go#L509-L545","documentation":"Hugo's JS batcher only supports the ES module output format. If externalOptions.Format (compiled from the options map) is set to anything other than \"esm\" — e.g. \"iife\", \"cjs\", \"umd\" — build() rejects it at batch.go:523-528. An empty format is auto-defaulted to \"esm\", so the error only fires when a non-esm value is explicitly provided.","triggerScenarios":"Passing options with Format set to \"iife\", \"cjs\", or any non-esm string to the JS batch/bundler options (e.g. via js.Build options or the batch config options map).","commonSituations":"Porting a non-Hugo esbuild config that used IIFE/UMD for legacy browsers; setting target/format options intended for a different bundler; copy-pasting an esbuild snippet with format: 'iife'.","solutions":["Set Format to \"esm\" (the default and only supported value).","Omit Format entirely so it defaults to \"esm\".","If you need IIFE/UMD output, use Hugo's js.Build resource transform with compatible options instead of the batcher."],"exampleFix":"// before\nopts := map[string]any{\"format\": \"iife\"}\n\n// after\nopts := map[string]any{\"format\": \"esm\"}\n// or simply omit \"format\"","handlingStrategy":"validation","validationCode":"func validateBatchFormat(opts map[string]any) error {\n    if f, ok := opts[\"format\"].(string); ok && f != \"\" && f != \"esm\" {\n        return fmt.Errorf(\"only esm format is currently supported (got %q)\", f)\n    }\n    return nil\n}","typeGuard":"func isSupportedFormat(f string) bool { return f == \"\" || f == \"esm\" }","tryCatchPattern":null,"preventionTips":["Omit 'format' so it defaults to \"esm\", or set it explicitly to \"esm\".","Avoid porting IIFE/UMD/CJS esbuild configs into the batcher.","Validate options maps before passing them to SetOptions/Build."],"tags":["esbuild","batch","js","format","esm"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}