Skip to content

Commit 79110e9

Browse files
jaysooFrozenPandaz
authored andcommitted
fix(core): gracefully handle non-existent files in find_imports (#29027)
<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes # (cherry picked from commit b16122d)
1 parent 93b906f commit 79110e9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/nx/src/native/plugins/js/ts_import_locators.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use anyhow::anyhow;
21
use std::collections::{HashMap, HashSet};
32
use std::fmt::Debug;
43
use std::path::Path;
@@ -541,9 +540,12 @@ fn process_file(
541540
(source_project, file_path): (&String, &String),
542541
) -> anyhow::Result<Option<ImportResult>> {
543542
let now = Instant::now();
544-
let cm = Arc::<SourceMap>::default()
543+
let Ok(cm) = Arc::<SourceMap>::default()
545544
.load_file(Path::new(file_path))
546-
.map_err(|e| anyhow!("Unable to load {}: {}", file_path, e))?;
545+
.inspect_err(|e| trace!("Unable to load {}: {}", file_path, e))
546+
else {
547+
return Ok(None);
548+
};
547549

548550
let comments = SingleThreadedComments::default();
549551

0 commit comments

Comments
 (0)