{"record":{"id":"bc40810bbbe1646b","repo":"denoland/deno","slug":"entry-point-must-be-a-file","errorCode":null,"errorMessage":"Entry point must be a file: {}","messagePattern":"Entry point must be a file: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/tools/bundle/mod.rs","lineNumber":492,"sourceCode":"\n  // Index emitted .d.ts files by their original source specifier\n  // TSC emits keys like \"file:///path/to/file.d.ts\" - map them back to source paths\n  let mut dts_by_source: std::collections::HashMap<String, String> =\n    std::collections::HashMap::new();\n  for (file_name, content) in &result.emitted_files {\n    // Map \"file:///path/to/mod.d.ts\" -> normalized source path\n    if let Ok(specifier) = Url::parse(file_name)\n      && let Ok(file_path) = specifier.to_file_path()\n    {\n      let source_path = file_path.to_string_lossy().to_string();\n      dts_by_source.insert(source_path, content.clone());\n    }\n  }\n\n  // For each entry point, produce a single rolled-up .d.ts\n  for entry_specifier in &entrypoint_specifiers {\n    let entry_path = entry_specifier.to_file_path().map_err(|_| {\n      deno_core::anyhow::anyhow!(\n        \"Entry point must be a file: {}\",\n        entry_specifier\n      )\n    })?;\n\n    // Find the .d.ts for this entry point\n    let dts_path = to_dts_path(&entry_path);\n    let entry_dts = dts_by_source\n      .get(&dts_path.to_string_lossy().to_string())\n      .ok_or_else(|| {\n        deno_core::anyhow::anyhow!(\n          \"No declaration file emitted for entry point: {}\",\n          entry_specifier\n        )\n      })?;\n\n    // Flatten: resolve all `export ... from \"...\"` re-exports by inlining\n    // the referenced declarations from other .d.ts files.","sourceCodeStart":474,"sourceCodeEnd":510,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/cli/tools/bundle/mod.rs#L474-L510","documentation":"During declaration emission, each entrypoint specifier is converted to a local file path to place the rolled-up .d.ts (Url::to_file_path, cli/tools/bundle/mod.rs:490-496). The conversion fails for any non-file:// scheme, so remote (https://) or data: entrypoints cannot produce declarations.","triggerScenarios":"'deno bundle --declaration https://example.com/mod.ts ...' or any entry that resolves to a remote/data specifier; piping an entry via a URL shortener/CDN in a build script.","commonSituations":"Build scripts that consume modules straight from a URL (common with jsr/std links); migrating a remote-entry workflow to --declaration.","solutions":["Download/mirror the remote module into the project and pass the local file as the entrypoint","If the remote module is small, vendor it (deno vendor-style copy or deno add for jsr) and import locally","Drop --declaration when the entrypoint must stay remote - declaration emission is local-files-only"],"exampleFix":"# before\ndeno bundle --declaration https://example.com/mod.ts --outdir dist\n# after: local entry\nDeno.writeTextFileSync('mod.ts', await (await fetch('https://example.com/mod.ts')).text());\ndeno bundle --declaration mod.ts --outdir dist","handlingStrategy":"type-guard","validationCode":"// Ensure every entrypoint is a local file before declaration bundling\nfunction assertLocalEntries(entries: string[]) {\n  for (const e of entries) {\n    if (new URL(e, import.meta.url).protocol !== 'file:') {\n      throw new Error(`declaration bundling requires a local entry: ${e}`);\n    }\n  }\n}","typeGuard":"function isFileUrl(specifier: string): specifier is `file://${string}` {\n  try { return new URL(specifier).protocol === 'file:'; } catch { return false; }\n}","tryCatchPattern":null,"preventionTips":["Vendor remote entry modules into the repo instead of bundling from URLs","Treat URL entrypoints and --declaration as mutually incompatible in build scripts"],"tags":["bundle","declarations","remote-modules","filesystem"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}