{"record":{"id":"c4017e64937fbbf2","repo":"parcel-bundler/parcel","slug":"unsupported-custom-svgo-plugin","errorCode":null,"errorMessage":"Unsupported custom SVGO plugin.","messagePattern":"Unsupported custom SVGO plugin\\.","errorType":"exception","errorClass":"ThrowableDiagnostic","httpStatus":null,"severity":"error","filePath":"packages/core/utils/src/svgo.js","lineNumber":136,"sourceCode":"          typeof params === 'object' &&\n          typeof params?.overrides === 'object' &&\n          params.overrides\n        ) {\n          for (let key in params.overrides) {\n            result[key] = params.overrides[key];\n          }\n        }\n      } else if (typeof name === 'string') {\n        result[(name: any)] = params || false;\n      }\n    }\n  }\n\n  return result;\n}\n\nasync function throwDiagnostic(message, filePath, jsonPath, fs, hint) {\n  throw new ThrowableDiagnostic({\n    diagnostic: {\n      message: message,\n      codeFrames: [\n        {\n          filePath: filePath,\n          codeHighlights:\n            path.extname(filePath) === '' || path.extname(filePath) === '.json'\n              ? generateJSONCodeHighlights(\n                  await fs.readFile(filePath, 'utf8'),\n                  [\n                    {\n                      key: jsonPath,\n                    },\n                  ],\n                )\n              : [],\n        },\n      ],","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/parcel-bundler/parcel/blob/59484858a1a0bcbb71f74088956bb437a2db6505/packages/core/utils/src/svgo.js#L118-L154","documentation":"Thrown by @parcel/utils svgo plugin normalization when a Parcel/SVGO config supplies a custom SVGO plugin as a function (plugin.fn is a function, or the plugin entry itself is a function). Parcel only supports SVGO's built-in named plugins, not user-supplied JS function plugins, so it emits a diagnostic via throwDiagnostic with a code frame pointing at the offending config location.","triggerScenarios":"Authoring a .parcelrc or SVG optimizer config whose svgo.plugins array contains an inline function plugin (e.g. `plugins: [() => {...}]` or `plugins: [{name:'x', fn: () => ...}]`) instead of a named built-in plugin string or name+params object.","commonSituations":"Porting a raw SVGO config (which allows custom plugins) into Parcel; tutorials suggesting function-based SVGO plugins; upgrading SVGO version where the plugin shape changed.","solutions":["Replace function plugins with the equivalent built-in named SVGO plugin (e.g. 'removeViewBox', 'mergePaths') and configure via params.","If you need custom transformation, pre-process the SVG with a separate tool/step before Parcel.","Remove the offending plugin entry from the config file highlighted in the diagnostic.","Consult SVGO's plugin list and map your custom function to the closest built-in."],"exampleFix":"// before — .svgo.json or parcel svgo config\n{\n  \"plugins\": [{ \"name\": \"mine\", \"fn\": () => ({}) }]\n}\n\n// after — use a built-in named plugin\n{\n  \"plugins\": [\"preset-default\", \"removeViewBox\"]\n}","handlingStrategy":"validation","validationCode":"// Reject function-based SVGO plugins before handing config to Parcel.\nfunction assertNoFunctionPlugins(svgoConfig) {\n  const plugins = svgoConfig?.plugins ?? [];\n  for (const p of plugins) {\n    if (typeof p === 'function' || (p && typeof p.fn === 'function')) {\n      throw new Error('Parcel does not support custom function SVGO plugins; use named built-ins.');\n    }\n  }\n}","typeGuard":"type NamedPlugin = string | { name: string; params?: object };\nfunction isNamedSVGOPlugin(p: unknown): p is NamedPlugin {\n  return typeof p === 'string' || (typeof p === 'object' && p !== null && typeof (p as any).name === 'string');\n}","tryCatchPattern":null,"preventionTips":["Use only built-in named SVGO plugins in Parcel configs.","Run custom SVG transforms in a pre-build step, not via SVGO plugin functions.","Keep raw SVGO configs out of Parcel; convert to named-plugin form."],"tags":["svgo","svg","config","optimizer","parcel"],"backgroundTag":null,"analyzedSha":"59484858a1a0bcbb71f74088956bb437a2db6505","analyzedAt":"2026-08-13T04:06:35.925Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}