{"record":{"id":"49c27814bdaf688c","repo":"denoland/deno","slug":"unsupported-media-type-for","errorCode":null,"errorMessage":"unsupported media type {} for {}","messagePattern":"unsupported media type (.+?) for (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"libs/eszip/v2.rs","lineNumber":1438,"sourceCode":"                }\n                _ => Cow::Borrowed(emit_options),\n              };\n              let emit = parsed_source\n                .transpile(\n                  transpile_options,\n                  &TranspileModuleOptions {\n                    module_kind: module_kind_provider.module_kind(module),\n                  },\n                  &emit_options,\n                )?\n                .into_source();\n              source = emit.text.into_bytes().into();\n              source_map = Arc::from(\n                emit.source_map.map(|s| s.into_bytes()).unwrap_or_default(),\n              );\n            }\n            _ => {\n              return Err(anyhow::anyhow!(\n                \"unsupported media type {} for {}\",\n                module.media_type,\n                visited.specifier()\n              ));\n            }\n          };\n\n          let eszip_module = EszipV2Module::Module {\n            kind: ModuleKind::JavaScript,\n            source: EszipV2SourceSlot::Ready(source),\n            source_map: EszipV2SourceSlot::Ready(source_map),\n          };\n          modules.insert(specifier_key.into_owned(), eszip_module);\n\n          Ok(Some(Box::new(module.dependencies.values().filter_map(\n            |dependency| {\n              Some(ToVisit::Module {\n                specifier: dependency.get_code()?,","sourceCodeStart":1420,"sourceCodeEnd":1456,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/libs/eszip/v2.rs#L1420-L1456","documentation":"Inside the JS-module arm of eszip v2 creation, only JavaScript, Mjs, Jsx, TypeScript, Mts, Tsx, Dts and Dmts media types are handled (passthrough or transpile). A Js module with any other media type — Css, Wasm, Html, SourceMap, Unknown, Cjs — hits the catch-all arm and errors.","triggerScenarios":"A module classified as JavaScript in the graph whose media type falls outside the supported set: importing .css/.wasm/.html/.cjs files, or files with unknown extensions that resolve as JS, into a graph fed to eszip.","commonSituations":"Bundling/compiling a project that imports stylesheets or wasm directly; renaming files to extensions deno_graph types as Unknown; .cjs entries in the graph.","solutions":["Remove direct imports of non-JS/TS assets from the entry graph (load CSS via link tags at runtime; load wasm with fetch + WebAssembly.instantiate)","Rename files to supported extensions (.js/.mjs/.jsx/.ts/.mts/.tsx/.d.ts/.d.mts)","Inspect the specifier named in the error to find which import produced the unsupported media type"],"exampleFix":"// before — CSS imported directly into the eszip-built graph\nimport \"./styles.css\";\n\n// after — keep CSS out of the bundle graph; inject at runtime\nconst link = document.createElement(\"link\");\nlink.rel = \"stylesheet\";\nlink.href = new URL(\"./styles.css\", import.meta.url).href;\ndocument.head.appendChild(link);","handlingStrategy":"validation","validationCode":"use deno_graph::Module;\n\n// reject graphs with unsupported media types before eszip creation\nfor module in graph.modules() {\n  if let Module::Js(js) = module {\n    let supported = matches!(\n      js.media_type,\n      deno_graph::MediaType::JavaScript\n        | deno_graph::MediaType::Mjs\n        | deno_graph::MediaType::Jsx\n        | deno_graph::MediaType::TypeScript\n        | deno_graph::MediaType::Mts\n        | deno_graph::MediaType::Tsx\n        | deno_graph::MediaType::Dts\n        | deno_graph::MediaType::Dmts\n    );\n    if !supported {\n      anyhow::bail!(\"unsupported media type {} for {}\", js.media_type, js.specifier);\n    }\n  }\n}","typeGuard":"fn is_eszip_supported(mt: deno_graph::MediaType) -> bool {\n  matches!(\n    mt,\n    deno_graph::MediaType::JavaScript\n      | deno_graph::MediaType::Mjs\n      | deno_graph::MediaType::Jsx\n      | deno_graph::MediaType::TypeScript\n      | deno_graph::MediaType::Mts\n      | deno_graph::MediaType::Tsx\n      | deno_graph::MediaType::Dts\n      | deno_graph::MediaType::Dmts\n  )\n}","tryCatchPattern":null,"preventionTips":["Keep the entry graph JS/TS-only; load CSS via link tags and wasm via fetch at runtime","Avoid importing .cjs files in graphs fed to eszip v2 creation — Cjs is not in the supported list","Use standard file extensions so deno_graph classifies modules correctly"],"tags":["eszip","media-type","transpile","compile","bundling"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}