parcel-bundler/parcel · error · ThrowableDiagnostic
Unsupported SVGR option "template".
Error message
Unsupported SVGR option "template".
What it means
Thrown by @parcel/transformer-svg-jsx when the SVGR config defines a `template` function. The new rust-based svgReact does not support custom SVGR templates (the function used by legacy SVGR to wrap the generated component). Like the jsx option, this is a deliberate incompatibility surfaced as a ThrowableDiagnostic with the `/template` JSON path and the same fallback hint.
Source
Thrown at packages/transformers/svg-jsx/src/SvgJsxTransformer.js:62
);
}
let svgr = svgrResult?.contents;
if (svgoResult && svgr?.jsx) {
throw new ThrowableDiagnostic({
diagnostic: await createDiagnostic(
md`
Unsupported SVGR option "jsx".
`,
svgrResult.filePath,
'/jsx',
options,
),
});
}
if (svgr?.template) {
throw new ThrowableDiagnostic({
diagnostic: await createDiagnostic(
md`
Unsupported SVGR option "template".
`,
svgrResult.filePath,
'/template',
options,
),
});
}
// Prefix ids by default so they don't conflict between svgs.
if (svgoConfig && svgoConfig.prefixIds == null) {
let hash = hashString(
relativePath(options.projectRoot, config.searchPath),
);
svgoConfig.prefixIds = {
prefix: hash.slice(-6),View on GitHub (pinned to 59484858a1)
Solutions
- Remove the `template` key from your SVGR config and accept the default output of svgReact.
- If the template does something load-bearing (custom props, displayName), either post-process the generated JSX with a SWC/Babel plugin, or switch to the legacy @parcel/transformer-svg-react via .parcelrc as the hint suggests.
Example fix
// before: svgr.config.js
module.exports = {
template: (variables, { tpl }) => tpl`${variables.componentName} = props => ...`,
};
// after (option a): drop the template
module.exports = {};
// after (option b): use legacy transformer in .parcelrc
"@parcel/transformer-svg-react" Defensive patterns
Strategy: validation
Validate before calling
function assertNoSVGRTemplate(config) {
if (config?.template) {
throw new Error('.svgrrc: template is not supported by @parcel/transformer-svg-jsx; remove it or switch to @parcel/transformer-svg-react');
}
} Prevention
- Move custom component-wrapping logic out of SVGR templates into a SWC/Babel plugin or a wrapper component.
- Keep .svgrrc minimal (icon, dimensions, etc.) when using the rust transformer.
When it happens
Trigger: loadConfig reads an SVGR config and `svgr.template` is truthy. Common when porting an SVGR config that customized component output (e.g. to add propTypes, displayName, or a custom wrapper).
Common situations: Existing SVGR config from a webpack/CRA project that defines a template; team template that injects defaultProps or width/height props; tutorial copy-paste that includes a template helper.
Related errors
- Unsupported SVGR option "jsx".
- Unsupported custom SVGO plugin.
- The 'elm.json' file is missing.
- PostCSS config should be an object.
- PostCSS config must have plugins
AI-assisted analysis of parcel-bundler/parcel@59484858a1 (2026-08-13).
Data as JSON: /api/errors/2b0b80002e74bc86.
Report an issue: GitHub.