{"record":{"id":"779e46ab20e863dc","repo":"vitejs/vite","slug":"no-corresponding-legacy-polyfill-chunk-found-for","errorCode":null,"errorMessage":"No corresponding legacy polyfill chunk found for ${htmlFilename}","messagePattern":"No corresponding legacy polyfill chunk found for (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/plugin-legacy/src/index.ts","lineNumber":820,"sourceCode":"        chunk.facadeModuleId,\n      )\n      if (legacyPolyfillFilename) {\n        tags.push({\n          tag: 'script',\n          attrs: {\n            nomodule: genModern,\n            crossorigin: true,\n            id: legacyPolyfillId,\n            src: toAssetPathFromHtml(\n              legacyPolyfillFilename,\n              chunk.facadeModuleId!,\n              config,\n            ),\n          },\n          injectTo: 'body',\n        })\n      } else if (legacyPolyfills.size) {\n        throw new Error(\n          `No corresponding legacy polyfill chunk found for ${htmlFilename}`,\n        )\n      }\n\n      // 5. inject legacy entry\n      const legacyEntryFilename = facadeToLegacyChunkMap.get(\n        chunk.facadeModuleId,\n      )\n      if (legacyEntryFilename) {\n        // `assets/foo.js` means importing \"named register\" in SystemJS\n        tags.push({\n          tag: 'script',\n          attrs: {\n            nomodule: genModern,\n            crossorigin: true,\n            // we set the entry path on the element as an attribute so that the\n            // script content will stay consistent - which allows using a constant\n            // hash value for CSP.","sourceCodeStart":802,"sourceCodeEnd":838,"githubUrl":"https://github.com/vitejs/vite/blob/b4d66fee14d970f45b8a6f3d7d6aee73ca9b88ab/packages/plugin-legacy/src/index.ts#L802-L838","documentation":"Symmetric to the modern case: when `genLegacy` is true and `legacyPolyfills.size > 0` but `facadeToLegacyPolyfillMap.get(chunk.facadeModuleId)` is undefined for an HTML entry, plugin-legacy cannot inject the `<script nomodule>` legacy polyfill chunk. The polyfill set was populated (configured or discovered) but no chunk was recorded for that facade.","triggerScenarios":"Setting `polyfills`/`additionalLegacyPolyfills` (so `legacyPolyfills` is non-empty) while the legacy polyfill chunk is not produced or not associated with the current HTML entry during `transformIndexHtml`.","commonSituations":"Custom `renderChunk`/output config that bypasses polyfill discovery for the legacy output. Multi-page builds where an entry's legacy polyfill chunk is missing. Mixing manually-cleared polyfill sets with enabled legacy generation.","solutions":["Confirm the legacy polyfill chunk exists in the build output (`dist/assets/polyfills-legacy-*.js`).","Remove custom `manualChunks`/`output` overrides that interfere with plugin-legacy's polyfill chunk generation.","If you don't need legacy polyfills, clear `polyfills`/`additionalLegacyPolyfills` so `legacyPolyfills.size` is 0.","Align vite and @vitejs/plugin-legacy versions."],"exampleFix":"// before\nplugins: [legacy({ polyfills: ['es.array.includes'], modernPolyfills: [] })],\nbuild: { rollupOptions: { output: { entryFileNames: '[name].js' /* strips polyfill naming */ } } },\n// after - keep default output handling\nplugins: [legacy({ polyfills: ['es.array.includes'] })],","handlingStrategy":"validation","validationCode":"function checkLegacyPolyfillsConfig(opts: { renderLegacyChunks?: boolean; polyfills?: unknown; additionalLegacyPolyfills?: unknown }) {\n  const genLegacy = opts.renderLegacyChunks !== false\n  const has = (Array.isArray(opts.polyfills) ? opts.polyfills.length : !!opts.polyfills)\n    || (Array.isArray(opts.additionalLegacyPolyfills) ? opts.additionalLegacyPolyfills.length : !!opts.additionalLegacyPolyfills)\n  if (!genLegacy && has) {\n    throw new Error('Legacy polyfills configured but renderLegacyChunks is false - chunk will be missing')\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await vite.build(cfg)\n} catch (e) {\n  if (e instanceof Error && /No corresponding legacy polyfill chunk/.test(e.message)) {\n    // stop interfering with the legacy polyfill chunk generation, then rebuild\n  } else throw e\n}","preventionTips":["Avoid custom plugins that delete or rename chunks containing 'polyfills-legacy'.","Confirm a polyfills-legacy-*.js file appears in dist/assets."],"tags":["plugin-legacy","polyfills","transform-index-html","build","legacy"],"backgroundTag":null,"analyzedSha":"b4d66fee14d970f45b8a6f3d7d6aee73ca9b88ab","analyzedAt":"2026-08-11T11:49:19.515Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}