vitejs/vite · error · Error
No corresponding modern polyfill chunk found for ${htmlFilen
Error message
No corresponding modern polyfill chunk found for ${htmlFilename} What it means
Thrown in transformIndexHtml when modern polyfills were detected (modernPolyfills.size > 0) but no modern polyfill chunk was associated with the current HTML entry's facadeModuleId. The plugin expects that if polyfills are collected, the buildPolyfillChunk call in generateBundle created a chunk and registered it in facadeToModernPolyfillMap. A missing entry means the polyfill chunk wasn't built or the facadeModuleId didn't match any chunk in the bundle during registration.
Source
Thrown at packages/plugin-legacy/src/index.ts:765
const modernPolyfillFilename = facadeToModernPolyfillMap.get(
chunk.facadeModuleId,
)
if (modernPolyfillFilename) {
tags.push({
tag: 'script',
attrs: {
type: 'module',
crossorigin: true,
src: toAssetPathFromHtml(
modernPolyfillFilename,
chunk.facadeModuleId!,
config,
),
},
})
} else if (modernPolyfills.size) {
throw new Error(
`No corresponding modern polyfill chunk found for ${htmlFilename}`,
)
}
}
if (!genLegacy) {
return { html, tags }
}
// 2. inject importmaps
if (config.build.chunkImportMap) {
const importMap = facadeToLegacyImportMap.get(chunk.facadeModuleId)!
const decoder = new TextDecoder()
tags.push({
tag: 'script',
attrs: { type: 'systemjs-importmap' },
children:
typeof importMap.source === 'string'View on GitHub (pinned to 89620f09af)
Solutions
- If you explicitly set modernPolyfills to true, try switching to an explicit array (e.g., modernPolyfills: ['es.array.flat']) to control which polyfills are included.
- Check that your rollupOptions.input HTML entries resolve to stable, real file paths (not virtual IDs).
- Update plugin-legacy; facadeModuleId matching has had fixes in newer versions.
- If using a custom plugin that alters entry resolution, ensure it preserves the original facadeModuleId.
Example fix
// before
legacy({ modernPolyfills: true })
// after — explicit list avoids auto-detection facade mismatches
legacy({ modernPolyfills: [
'es.array.flat', 'es.promise', 'es.object.from-entries'
] }) Defensive patterns
Strategy: validation
Validate before calling
// Pre-validate that HTML entries have stable facadeModuleId values
function validateHtmlEntries(input) {
const entries = typeof input === 'object' ? Object.values(input) : [input]
for (const entry of entries) {
if (typeof entry !== 'string' || !entry.endsWith('.html')) {
console.warn(`Input ${entry} may not resolve to a stable HTML facadeModuleId`)
}
}
}
validateHtmlEntries(config.build.rollupOptions.input) Type guard
function hasExplicitModernPolyfills(options: Options): boolean {
return Array.isArray(options.modernPolyfills)
}
// prefer explicit to avoid auto-detection facade issues
if (!hasExplicitModernPolyfills(opts)) {
console.warn('Consider setting modernPolyfills to an explicit array for multi-page apps')
} Try / catch
try {
await build({ plugins: [legacy({ modernPolyfills: explicitList })] })
} catch (e) {
if (e.message.includes('No corresponding modern polyfill chunk')) {
console.error('Polyfill/entry facade mismatch. Try explicit modernPolyfills array.')
}
throw e
} Prevention
- For multi-page apps, use explicit modernPolyfills arrays instead of auto-detection (true).
- Ensure rollupOptions.input HTML files resolve to real file system paths.
- Test each HTML entry independently to isolate which one triggers the mismatch.
When it happens
Trigger: Multi-page apps where HTML entry files have unusual facadeModuleId values (e.g., virtual modules, custom resolveId). Also triggered when modernPolyfills is set to true (auto-detect) and polyfills are found, but the entry chunk's facadeModuleId is null or doesn't match what was registered during buildPolyfillChunk's bundle iteration.
Common situations: Using custom HTML entry resolution, multi-page setups with rollupOptions.input containing HTML files, or plugins that intercept entry module IDs. Can also happen when MPA input keys don't align with facadeModuleId after transformation.
Related errors
- No corresponding legacy polyfill chunk found for ${htmlFilen
- Internal @vitejs/plugin-legacy error: discovered polyfills s
- Internal @vitejs/plugin-legacy error: discovered polyfills f
- No corresponding legacy entry chunk found for ${htmlFilename
- { runtime: "${result.runtime}" } is not supported for assets
AI-assisted analysis of vitejs/vite@89620f09af (2026-08-03).
Data as JSON: /data/errors/15e85c39acce792f.json.
Report an issue: GitHub.