harn_modules/
standalone.rs1use std::collections::HashMap;
2use std::path::Path;
3
4use super::{build_inner, normalize_path, ModuleGraph, ParsedSourceRetention};
5
6#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
10pub(super) enum PackageContext {
11 #[default]
12 Project,
13 Standalone,
14}
15
16pub fn build_with_standalone_source(file: &Path, source: &str) -> ModuleGraph {
19 let file = normalize_path(file);
20 let source_overrides = HashMap::from([(file.clone(), source.to_string())]);
21 build_inner(
22 &[file],
23 ParsedSourceRetention::None,
24 Some(&source_overrides),
25 PackageContext::Standalone,
26 )
27 .graph
28}