in compiler/crates/relay-compiler/src/config.rs [715:813]
fn create_multi_project_config(self, config_path: &Path) -> Result<MultiProjectConfigFile> {
if !self.include.is_empty() {
warn!(
r#"The configuration contains `include: {:#?}` section. This configuration option is no longer supported. Consider removing it."#,
&self.include
);
}
if !self.extensions.is_empty() {
warn!(
r#"The configuration contains `extensions: {:#?}` section. This configuration option is no longer supported. Consider removing it."#,
&self.extensions
);
}
if self.typegen_phase.is_some() {
return Err(Error::ConfigFileValidation {
config_path: config_path.into(),
validation_errors: vec![ConfigValidationError::RemovedConfigField {
name: "typegenPhase",
action: "Please remove the option and update type imports from generated files to new names.",
}],
});
}
let current_dir = std::env::current_dir().unwrap();
let common_root_dir = self.get_common_root(current_dir.clone()).map_err(|err| {
Error::ConfigFileValidation {
config_path: config_path.to_path_buf(),
validation_errors: vec![err],
}
})?;
let language = self.language.ok_or_else(|| {
let mut variants = vec![];
for lang in TypegenLanguage::get_variants_as_string() {
variants.push(format!(r#" "language": "{}""#, lang));
}
Error::ConfigError {
details: format!("The `language` option is missing in the Relay configuration file. Please, specify one of the following options:\n{}", variants.join("\n")),
}
}
)?;
let project_config = ConfigFileProject {
output: self.artifact_directory.map(|dir| {
normalize_path_from_config(current_dir.clone(), common_root_dir.clone(), dir)
}),
schema: Some(normalize_path_from_config(
current_dir.clone(),
common_root_dir.clone(),
self.schema,
)),
schema_config: self.schema_config,
schema_extensions: self
.schema_extensions
.iter()
.map(|dir| {
normalize_path_from_config(
current_dir.clone(),
common_root_dir.clone(),
dir.clone(),
)
})
.collect(),
persist: self.persist_config,
typegen_config: TypegenConfig {
language,
custom_scalar_types: self.custom_scalars.clone(),
eager_es_modules: self.eager_es_modules,
flow_typegen: FlowTypegenConfig {
no_future_proof_enums: self.no_future_proof_enums,
..Default::default()
},
..Default::default()
},
js_module_format: self.js_module_format,
feature_flags: self.feature_flags,
..Default::default()
};
let mut projects = FnvIndexMap::default();
projects.insert(self.project_name, project_config);
let mut sources = FnvIndexMap::default();
let src = normalize_path_from_config(current_dir, common_root_dir.clone(), self.src);
sources.insert(src, ProjectSet::of(self.project_name));
Ok(MultiProjectConfigFile {
root: Some(common_root_dir),
projects,
sources,
excludes: self.excludes,
is_dev_variable_name: self.is_dev_variable_name,
codegen_command: self.codegen_command,
..Default::default()
})
}