{"record":{"id":"d1980058b7dd0da4","repo":"facebook/relay","slug":"unexpected-jsmoduledependency","errorCode":null,"errorMessage":"Unexpected JSModuleDependency","messagePattern":"Unexpected JSModuleDependency","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/crates/relay-codegen/src/printer.rs","lineNumber":933,"sourceCode":"                        write_constant_value(f, builder, value)?;\n                        f.push(',');\n                    }\n                    if !obj.is_empty() {\n                        f.pop();\n                    }\n                    f.push('}');\n                    Ok(())\n                }\n            }\n        }\n        Primitive::Null | Primitive::SkippableNull => {\n            f.push_str(\"null\");\n            Ok(())\n        }\n        Primitive::StorageKey(_, _) => panic!(\"Unexpected StorageKey\"),\n        Primitive::RawString(_) => panic!(\"Unexpected RawString\"),\n        Primitive::GraphQLModuleDependency(_) => panic!(\"Unexpected GraphQLModuleDependency\"),\n        Primitive::JSModuleDependency { .. } => panic!(\"Unexpected JSModuleDependency\"),\n        Primitive::ResolverModuleReference { .. } => panic!(\"Unexpected ResolverModuleReference\"),\n        Primitive::PropertyAccessor(_) => panic!(\"Unexpected PropertyAccessor\"),\n        Primitive::DynamicImport { .. } => panic!(\"Unexpected DynamicImport\"),\n        Primitive::RelayResolverModel { .. } => panic!(\"Unexpected RelayResolver\"),\n    }\n}\n","sourceCodeStart":915,"sourceCodeEnd":940,"githubUrl":"https://github.com/facebook/relay/blob/668b1b85e06261aa3b58dabfc51f8b5524a70955/compiler/crates/relay-codegen/src/printer.rs#L915-L940","documentation":"Primitive::JSModuleDependency represents a required JS module import (e.g. from @match or client extensions) and is emitted via module import statements, never as a constant value. write_constant_value panics if such a dependency appears in an argument or embedded literal position, since there is no valid JS literal for a module reference in that context.","triggerScenarios":"A JSModuleDependency primitive produced by the builder for @match/client-extension handling reaching an argument value or constant position during printing; custom transforms inserting JS module dependencies into argument values.","commonSituations":"Using @match/@module features where the dependency ends up in an argument position instead of a selection; custom codegen passes constructing JSModuleDependency Primitives in the wrong slot; compiler upgrade changing where dependencies are emitted.","solutions":["Ensure module dependencies are only produced in module/import positions (write_module_import path), not in arguments","Restructure the document so @match/@module usage keeps dependencies in selections rather than arguments","Fix custom transforms to use the proper import mechanism instead of embedding dependencies in values","Update the Relay compiler to a version whose IR/printer contract matches your pipeline"],"exampleFix":"// before\nargument: <JSModuleDependency(\"./Avatar_user.react\")> // inside an argument value\n// after\nargument: \"Avatar_user\" // plain string literal; import emitted via module path","handlingStrategy":"validation","validationCode":"function assertNoJsDepsInArgs(doc) {\n  visit(doc, {\n    Argument(node) {\n      if (node.value.kind !== 'Variable' && !isLiteralValue(node.value)) {\n        throw new Error(`Argument ${node.name.value} must be a literal value`);\n      }\n    }\n  });\n}","typeGuard":"const isJsDep = (p) => p != null && p.type === 'jsModuleDependency';","tryCatchPattern":"try {\n  generateArtifacts();\n} catch (e) {\n  if (String(e).includes('Unexpected JSModuleDependency')) {\n    // route module imports through the import path, not arguments\n  }\n  throw e;\n}","preventionTips":["Emit JS module dependencies only via import statements in generated artifacts","Keep arguments strictly to literal values","Review custom codegen passes for misplaced dependency primitives","Keep transforms and printer in the same compiler version"],"tags":["compiler","codegen","js-module-dependency","primitive"],"backgroundTag":"unexpected-primitive-kind","analyzedSha":"668b1b85e06261aa3b58dabfc51f8b5524a70955","analyzedAt":"2026-09-02T19:57:20.783Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}