diff options
Diffstat (limited to 'cli/module_loader.rs')
-rw-r--r-- | cli/module_loader.rs | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/cli/module_loader.rs b/cli/module_loader.rs index 445cf4902..f79576108 100644 --- a/cli/module_loader.rs +++ b/cli/module_loader.rs @@ -224,10 +224,7 @@ impl ModuleLoadPreparer { ) -> Result<(), AnyError> { let lib = self.options.ts_type_lib_window(); - let specifiers = files - .iter() - .map(|file| resolve_url_or_path(file, self.options.initial_cwd())) - .collect::<Result<Vec<_>, _>>()?; + let specifiers = self.collect_specifiers(files); self .prepare_module_load( specifiers, @@ -237,6 +234,30 @@ impl ModuleLoadPreparer { ) .await } + + fn collect_specifiers(&self, files: &[String]) -> Vec<ModuleSpecifier> { + let excludes = match self.options.resolve_check_options() { + Ok(o) => o.exclude, + Err(_) => vec![], + }; + files + .iter() + .filter_map(|file| { + let file_url = + resolve_url_or_path(file, self.options.initial_cwd()).ok()?; + if file_url.scheme() != "file" { + return Some(file_url); + } + // ignore local files that match any of files listed in `exclude` option + let file_path = file_url.to_file_path().ok()?; + if excludes.iter().any(|e| file_path.starts_with(e)) { + None + } else { + Some(file_url) + } + }) + .collect::<Vec<_>>() + } } pub struct ModuleCodeSource { |