{"record":{"id":"bf88837022859c96","repo":"vitejs/vite","slug":"renderlegacychunks-and-rendermodernchunks-cann","errorCode":null,"errorMessage":"`renderLegacyChunks` and `renderModernChunks` cannot be both false","messagePattern":"`renderLegacyChunks` and `renderModernChunks` cannot be both false","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/plugin-legacy/src/index.ts","lineNumber":218,"sourceCode":"\nfunction resolveLegacyBuildMinify(\n  minify: BuildOptions['minify'],\n  supportsOxc: boolean | undefined,\n): BuildOptions['minify'] {\n  const usesOxc = supportsOxc && (minify === 'oxc' || minify === true)\n  return usesOxc ? 'oxc' : minify ? 'terser' : false\n}\n\nfunction viteLegacyPlugin(options: Options = {}): Plugin[] {\n  let config: ResolvedConfig\n  let targets: Options['targets']\n  const modernTargets: Options['modernTargets'] =\n    options.modernTargets || modernTargetsBabel\n\n  const genLegacy = options.renderLegacyChunks !== false\n  const genModern = options.renderModernChunks !== false\n  if (!genLegacy && !genModern) {\n    throw new Error(\n      '`renderLegacyChunks` and `renderModernChunks` cannot be both false',\n    )\n  }\n\n  const debugFlags = (process.env.DEBUG || '').split(',')\n  const isDebug =\n    debugFlags.includes('vite:*') || debugFlags.includes('vite:legacy')\n\n  const assumptions = options.assumptions || {}\n\n  const facadeToLegacyChunkMap = new Map()\n  const facadeToLegacyImportMap = new Map<string | null, Rollup.OutputAsset>()\n  const facadeToLegacyPolyfillMap = new Map()\n  const facadeToModernPolyfillMap = new Map()\n  const modernPolyfills = new Set<string>()\n  const legacyPolyfills = new Set<string>()\n  // When discovering polyfills in `renderChunk`, the hook may be non-deterministic, so we group the\n  // modern and legacy polyfills in a sorted chunks map for each rendered outputs before merging them.","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/vitejs/vite/blob/b4d66fee14d970f45b8a6f3d7d6aee73ca9b88ab/packages/plugin-legacy/src/index.ts#L200-L236","documentation":"plugin-legacy has two independent toggles: `renderLegacyChunks` (default true) controls whether SystemJS-based legacy bundles are emitted, and `renderModernChunks` (default true) controls whether modern bundles/polyfills are emitted. Setting BOTH to false means the plugin would emit no output at all, which is an invalid configuration, so the plugin rejects it eagerly in `viteLegacyPlugin()`.","triggerScenarios":"Passing `{ renderLegacyChunks: false, renderModernChunks: false }` to `legacy()` in the Vite plugins array. This can happen when trying to use plugin-legacy purely for its polyfill detection while disabling both chunk kinds, or when conditionally computing flags that both evaluate to false.","commonSituations":"Trying to 'disable' plugin-legacy at runtime by flipping both flags to false instead of removing the plugin from the array. Copying an options object and toggling the wrong flag. Migrating between plugin versions where flag semantics changed.","solutions":["Remove the `legacy()` plugin from the Vite plugins array entirely if you want no legacy/modern processing.","Keep at least one of the two flags at its default `true` (leave `renderModernChunks` unset while setting only `renderLegacyChunks: false`, or vice versa).","If you only want polyfills without legacy SystemJS output, set `renderLegacyChunks: false` and provide `modernPolyfills` while leaving `renderModernChunks` at its default."],"exampleFix":"// before\nlegacy({ renderLegacyChunks: false, renderModernChunks: false }),\n// after - just drop the plugin\n// (remove the `legacy(...)` line from plugins)","handlingStrategy":"validation","validationCode":"function validateLegacyOptions(opts: { renderLegacyChunks?: boolean; renderModernChunks?: boolean }) {\n  if (opts.renderLegacyChunks === false && opts.renderModernChunks === false) {\n    throw new Error('At least one of renderLegacyChunks/renderModernChunks must be true (or both left default).')\n  }\n}","typeGuard":"function isLegalLegacyOptions(o: unknown): boolean {\n  if (!o || typeof o !== 'object') return true\n  const { renderLegacyChunks, renderModernChunks } = o as any\n  return !(renderLegacyChunks === false && renderModernChunks === false)\n}","tryCatchPattern":null,"preventionTips":["To disable legacy entirely, remove the legacy() plugin instead of flipping both flags.","Only ever set ONE of the two flags to false; leave the other at its default."],"tags":["plugin-legacy","config-validation","build"],"backgroundTag":null,"analyzedSha":"b4d66fee14d970f45b8a6f3d7d6aee73ca9b88ab","analyzedAt":"2026-08-11T11:49:19.515Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}