{"record":{"id":"ca8c6cbf680a4441","repo":"rolldown/rolldown","slug":"should-have-common-dir-for-entries","errorCode":null,"errorMessage":"should have common dir for entries","messagePattern":"should have common dir for entries","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/rolldown/src/module_loader/external_module_task.rs","lineNumber":77,"sourceCode":"        id,\n        is_entry: false,\n        importers: FxIndexSet::default(),\n        dynamic_importers: FxIndexSet::default(),\n        imported_ids: FxIndexSet::default(),\n        dynamically_imported_ids: FxIndexSet::default(),\n        exports: vec![],\n        input_format: ExportsKind::None,\n      }),\n    );\n\n    let need_renormalize_render_path =\n      !matches!(resolved_id.external, ResolvedExternal::Absolute) && resolved_id.id.is_path();\n\n    let file_name: ArcStr = if need_renormalize_render_path {\n      let entries_common_dir = commondir::common_dir(\n        self.user_defined_entries.iter().map(|(_, resolved_id)| resolved_id.id.as_str()),\n      )\n      .expect(\"should have common dir for entries\");\n      let relative_path = Path::new(resolved_id.id.as_str()).relative(&entries_common_dir);\n      ArcStr::from(relative_path.to_slash())\n    } else {\n      resolved_id.id.as_arc_str().clone()\n    };\n\n    let identifier_name: ArcStr = if need_renormalize_render_path {\n      let relative_path = Path::new(resolved_id.id.as_str()).relative(&self.ctx.options.cwd);\n      ArcStr::from(relative_path.to_slash())\n    } else {\n      resolved_id.id.as_arc_str().clone()\n    };\n    let legitimized_identifier_name = legitimize_identifier_name(&identifier_name);\n    let msg = ModuleLoaderMsg::ExternalModuleDone(Box::new(ExternalModuleTaskResult {\n      idx: self.module_idx,\n      id: resolved_id.id.clone(),\n      name: file_name,\n      identifier_name: legitimized_identifier_name.into(),","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/rolldown/rolldown/blob/91b44b9d7bcfb5725533478e044e3891a251b2c5/crates/rolldown/src/module_loader/external_module_task.rs#L59-L95","documentation":"For external module ids that need path renormalization, rolldown computes the common directory of all user-defined entries via `commondir::common_dir` and makes the external module path relative to it. `common_dir` returns `None` when no common directory exists (e.g. paths on different roots/drives or an empty entry list), and this `expect` turns that into a panic.","triggerScenarios":"Declaring entries whose absolute paths share no common prefix (different drives on Windows, e.g. `C:\\src` and `D:\\lib`), or having no user-defined entries while an external module still requires renormalization.","commonSituations":"Windows monorepos spread across drives; programmatic API usage with entries on mixed mount points; constructing a bundler programmatically without registering entries before resolving externals.","solutions":["Place all entries under a common root directory/drive","On Windows, avoid mixing drives (C:, D:) across entry paths","Ensure user-defined entries are registered before the build when using the programmatic API","Mark the module external with an absolute-path strategy that skips renormalization"],"exampleFix":"// before\nentry: { main: 'C:/repo/main.ts', vendor: 'D:/shared/vendor.ts' }\n// after\nentry: { main: 'C:/repo/main.ts', vendor: 'C:/repo/vendor.ts' }","handlingStrategy":"validation","validationCode":"function assertCommonRoot(entries) {\n  const drives = new Set(entries.map(e => e.replace(/^[A-Za-z]:/, '').split(/[\\\\/]/)[0]));\n  const roots = new Set(entries.map(e => e.split(/[\\\\/]/)[0]));\n  if (roots.size > 1) throw new Error(`Entries share no common dir: ${[...roots].join(', ')}`);\n}\n// call before building: assertCommonRoot(Object.values(config.input))","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep all entry files under one project root (and one drive on Windows)","Use relative entry paths resolved from the project root","Register entries before resolving externals when using the programmatic API"],"tags":["paths","entries","windows","commondir"],"backgroundTag":"resource-not-found","analyzedSha":"91b44b9d7bcfb5725533478e044e3891a251b2c5","analyzedAt":"2026-09-07T16:04:13.504Z","contentChangedAt":"2026-09-07T16:04:13.504Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}