{"record":{"id":"e214f62355f11bdb","repo":"facebook/docusaurus","slug":"html-minification-failed-swc","errorCode":null,"errorMessage":"HTML minification failed (SWC)","messagePattern":"HTML minification failed \\(SWC\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/docusaurus-bundler/src/minifyHtml.ts","lineNumber":118,"sourceCode":"          removeRedundantAttributes: 'none',\n\n          minifyJs: true,\n          minifyJson: true,\n          minifyCss: true,\n        });\n\n        const warnings = (result.errors ?? []).map((diagnostic) => {\n          return `[HTML minifier diagnostic - ${diagnostic.level}] ${\n            diagnostic.message\n          } - ${JSON.stringify(diagnostic.span)}`;\n        });\n\n        return {\n          code: result.code,\n          warnings,\n        };\n      } catch (err) {\n        throw new Error(`HTML minification failed (SWC)`, {\n          cause: err,\n        });\n      }\n    },\n  };\n}\n","sourceCodeStart":100,"sourceCodeEnd":125,"githubUrl":"https://github.com/facebook/docusaurus/blob/3f483e80e326cc646b54b83d564b3f0c4881b9a6/packages/docusaurus-bundler/src/minifyHtml.ts#L100-L125","documentation":"Thrown by the SWC HTML minifier wrapper in @docusaurus/bundler when @swc/html fails to minify a page's HTML during build with Docusaurus Faster enabled (getSwcMinifier). The original SWC error is attached as `cause`. This is the faster/SWC counterpart of the Terser minifier error.","triggerScenarios":"Building with future.faster enabled and the SWC HTML minifier selected, when @swc/html cannot process the rendered HTML of a route. Reached via importSwcHtmlMinifier -> faster.getSwcHtmlMinifier -> swcHtmlMinifier(Buffer).","commonSituations":"Malformed HTML from a custom theme component; an inline <script>/<style> block SWC cannot re-minify; an @docusaurus/faster or @swc/core version mismatch after an upgrade.","solutions":["Inspect err.cause for the SWC diagnostic (byte span + message) and fix the offending HTML.","Temporarily set SKIP_HTML_MINIFICATION=true to unblock the build and confirm the minifier is the culprit.","Align @docusaurus/faster and @swc/core versions with the ones Docusaurus recommends for your version.","Fall back to the Terser minifier by disabling future.faster htmlMinifier if SWC is incompatible with your markup."],"exampleFix":"# isolate\nSKIP_HTML_MINIFICATION=true npm run build\n# then fix the markup reported in err.cause.span","handlingStrategy":"try-catch","validationCode":"// no inline pre-check; isolate with:\n// process.env.SKIP_HTML_MINIFICATION = 'true'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin @docusaurus/faster and @swc/core to a compatible pair.","Use SKIP_HTML_MINIFICATION=true to confirm the minifier is the culprit.","Fall back to Terser if SWC rejects markup you cannot change."],"tags":["bundler","html-minification","swc","faster","build","wrapped-error"],"backgroundTag":null,"analyzedSha":"3f483e80e326cc646b54b83d564b3f0c4881b9a6","analyzedAt":"2026-08-12T13:25:04.382Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}