{"record":{"id":"6ec532ec77b32995","repo":"denoland/deno","slug":"cannot-represent-compiler-option-name-as-a-gen","errorCode":null,"errorMessage":"Cannot represent compiler option '{name}' as a generated JSX pragma.","messagePattern":"Cannot represent compiler option '(.+?)' as a generated JSX pragma\\.","errorType":"exception","errorClass":"AnyError","httpStatus":null,"severity":"error","filePath":"cli/tools/publish/module_content.rs","lineNumber":32,"sourceCode":"use deno_graph::ModuleGraph;\nuse deno_resolver::cache::LazyGraphSourceParser;\nuse deno_resolver::cache::ParsedSourceCache;\nuse deno_resolver::deno_json::CompilerOptionsResolver;\nuse deno_resolver::workspace::ResolutionKind;\nuse lazy_regex::Lazy;\n\nuse super::diagnostics::PublishDiagnostic;\nuse super::diagnostics::PublishDiagnosticsCollector;\nuse super::unfurl::PositionOrSourceRangeRef;\nuse super::unfurl::SpecifierUnfurler;\nuse super::unfurl::SpecifierUnfurlerDiagnostic;\nuse super::unfurl::SpecifierUnfurlerSys;\nuse crate::sys::CliSys;\nuse crate::tools::unfurl_utils::is_safe_unquoted_comment_value;\n\nfn jsx_pragma(name: &str, value: &str) -> Result<String, AnyError> {\n  if !is_safe_unquoted_comment_value(value) {\n    return Err(deno_core::anyhow::anyhow!(\n      \"Cannot represent compiler option '{name}' as a generated JSX pragma.\"\n    ));\n  }\n  Ok(format!(\"/** @{name} {value} */\"))\n}\n\nstruct JsxFolderOptions<'a> {\n  jsx_runtime: &'static str,\n  jsx_classic: Option<Cow<'a, deno_ast::JsxClassicOptions>>,\n  jsx_import_source: Option<String>,\n  jsx_import_source_types: Option<String>,\n}\n\n#[sys_traits::auto_impl]\npub trait ModuleContentProviderSys: SpecifierUnfurlerSys {}\n\npub struct ModuleContentProvider<TSys: ModuleContentProviderSys = CliSys> {\n  specifier_unfurler: SpecifierUnfurler<TSys>,","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/tools/publish/module_content.rs#L14-L50","documentation":"While 'unfurling' sources during `deno publish`, Deno rewrites per-file compiler options into a leading comment pragma (e.g. `/** @jsxImportSource react */`). A pragma is unquoted source text, so the value must be safe to embed: non-empty, no `*/` (would close the comment), and no whitespace or control characters (checked by `is_safe_unquoted_comment_value`). If a JSX-related compiler option value violates those rules, Deno cannot represent it and fails with this error.","triggerScenarios":"`\"jsxImportSource\": \"my lib\"` (space inside the specifier); a jsxFactory/jsxFragmentFactory value containing whitespace or `*/`; an empty value for one of these options in deno.json or a per-file pragma that publish tries to regenerate.","commonSituations":"Copying a JSX config from a bundler where free-form strings are allowed; editor auto-inserting a trailing space into jsxImportSource; unusual jsxFactory names with spaces. Only surfaces during publish because that is when pragmas are generated for the shipped tarball.","solutions":["Fix the offending compiler option in deno.json to be a plain identifier/specifier with no whitespace: `\"jsxImportSource\": \"react\"` (or your runtime package).","Check jsxFactory/jsxFragmentFactory values too — they must be valid unquoted pragma tokens (letters, digits, `_`, `$`, `.`, `/`, `-`).","Remove an empty-string JSX option instead of setting it to \"\".","Re-run `deno publish --dry-run` to confirm unfurling succeeds."],"exampleFix":"// before (deno.json)\n{\n  \"compilerOptions\": {\n    \"jsxImportSource\": \"preact/compat \"\n  }\n}\n\n// after\n{\n  \"compilerOptions\": {\n    \"jsxImportSource\": \"preact/compat\"\n  }\n}","handlingStrategy":"validation","validationCode":"function isSafePragmaValue(v: string): boolean {\n  return v.length > 0 &&\n    !v.includes('*/') &&\n    ![...v].some((c) => /\\s|\\p{Cc}/u.test(c));\n}\n\nconst jsxImportSource = denoJson.compilerOptions?.jsxImportSource ?? '';\nif (!isSafePragmaValue(jsxImportSource)) {\n  throw new Error(`jsxImportSource cannot be embedded as a pragma: ${jsxImportSource}`);\n}","typeGuard":"const isSafePragmaValue = (v: string): boolean =>\n  v.length > 0 && !v.includes('*/') && !/\\s|\\p{Cc}/u.test(v);","tryCatchPattern":"try {\n  await runDeno(['publish']);\n} catch (e) {\n  if (String(e.message).includes('generated JSX pragma')) {\n    // normalize the offending JSX option in deno.json (strip whitespace/`*/`) and retry\n  }\n}","preventionTips":["Keep jsxImportSource/jsxFactory/jsxFragmentFactory values as plain specifiers/identifiers with no spaces.","Lint config files for stray whitespace in compiler option values.","Run `deno publish --dry-run` to exercise unfurling before the real publish."],"tags":["publish","jsr","jsx","pragma","unfurl","compiler-options"],"backgroundTag":"invalid-config-value","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}