{"record":{"id":"631bba96a3666daa","repo":"denoland/deno","slug":"unsupported-media-type-for-snapshotting-media-typ","errorCode":null,"errorMessage":"Unsupported media type for snapshotting {media_type:?} for file {}","messagePattern":"Unsupported media type for snapshotting (.+?) for file (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"runtime/transpile.rs","lineNumber":87,"sourceCode":"  let source = maybe_substitute_node_version(&name_string, source);\n  // Always transpile `node:` built-in modules, since they might be TypeScript.\n  let media_type = if name.starts_with(\"node:\") {\n    MediaType::TypeScript\n  } else {\n    MediaType::from_path(Path::new(&name))\n  };\n\n  match media_type {\n    MediaType::TypeScript => {}\n    MediaType::JavaScript | MediaType::Mjs => {\n      if minify {\n        let source =\n          minify_source_with_rolldown(&name_string, source.as_ref())?;\n        return Ok((source.into(), None));\n      }\n      return Ok((source, None));\n    }\n    _ => panic!(\n      \"Unsupported media type for snapshotting {media_type:?} for file {}\",\n      name\n    ),\n  }\n\n  let parsed = deno_ast::parse_module(ParseParams {\n    specifier: deno_core::url::Url::parse(&name).unwrap(),\n    text: source.into(),\n    media_type,\n    capture_tokens: false,\n    scope_analysis: false,\n    maybe_syntax: None,\n  })\n  .map_err(|e| JsErrorBox::from_err(JsParseDiagnostic(e)))?;\n  let transpiled_source = parsed\n    .transpile(\n      &deno_ast::TranspileOptions {\n        imports_not_used_as_values: deno_ast::ImportsNotUsedAsValues::Remove,","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/runtime/transpile.rs#L69-L105","documentation":"When preparing startup snapshot inputs, runtime/transpile.rs accepts only TypeScript, JavaScript, and Mjs sources. Any other media type (JSX, TSX, JSON, CSS, etc.) reaches a panic because the snapshot transpile path has no emitter for it.","triggerScenarios":"Feeding a .jsx, .tsx, .json, .css, or other non-JS/TS file into snapshot/transpile input - e.g. a custom snapshot build script that globs a directory containing mixed file types.","commonSituations":"Custom embedders building snapshots with broad file globs; workspaces where JSX files sit next to JS; bundler outputs containing unexpected extensions.","solutions":["Filter snapshot inputs to .js/.mjs/.ts before invoking the transpile step","Pre-transpile JSX/TSX to plain JS yourself if those files must be snapshotted","Point the snapshot build at an explicit file list instead of a directory glob"],"exampleFix":"// before\nlet files = std::fs::read_dir(dir)?; // picks up app.jsx -> panic\n\n// after\nlet files = std::fs::read_dir(dir)?.filter(|e| {\n  matches!(\n    e.as_ref().ok().and_then(|e| e.path().extension().and_then(|s| s.to_str())),\n    Some(\"js\") | Some(\"mjs\") | Some(\"ts\")\n  )\n});","handlingStrategy":"validation","validationCode":"fn snapshottable(path: &std::path::Path) -> bool {\n  matches!(\n    path.extension().and_then(|s| s.to_str()),\n    Some(\"js\") | Some(\"mjs\") | Some(\"ts\")\n  )\n}\n\nfor path in inputs {\n  if !snapshottable(&path) {\n    return Err(format!(\"{} is not snapshottable; pre-transpile or exclude it\", path.display()));\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use an explicit allowlist of input files for snapshot builds instead of directory globs","Pre-transpile JSX/TSX to JS before feeding the snapshot step","Fail on unknown extensions during build configuration, not inside the transpile path"],"tags":["snapshot","transpile","media-type","build","panic"],"backgroundTag":"unsupported-media-type","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}