Skip to content

Commit

Permalink
Merge pull request #320 from github/new_js_more_changes
Browse files Browse the repository at this point in the history
Port more changes to JS rules
  • Loading branch information
BekaValentine authored Oct 19, 2023
2 parents 2c6de63 + d067d27 commit 169c94f
Show file tree
Hide file tree
Showing 57 changed files with 1,547 additions and 230 deletions.
1 change: 0 additions & 1 deletion languages/tree-sitter-stack-graphs-javascript/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ clap = { version = "4", optional = true }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
stack-graphs = { version = "0.12", path = "../../stack-graphs" }
tree-sitter = "=0.20.9"
tree-sitter-stack-graphs = { version = "0.7", path = "../../tree-sitter-stack-graphs" }
tree-sitter-javascript = { git = "https://github.com/tree-sitter/tree-sitter-javascript", rev = "5720b249490b3c17245ba772f6be4a43edb4e3b7" }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ impl FileAnalyzer for NpmPackageAnalyzer {
// [root] -> [pop "GUARD:PKG"] -> [pop PKG_NAME]* -> [push PKG_INTERNAL_NAME] -> [push "GUARD:PKG_INTERNAL"] -> [root]
//
if !npm_pkg.name.is_empty() {
// NOTE Because all modules expose their exports at the top-level, both paths created below are equivalent for
// exports of the main module. This means multiple equivalent paths to those exports, which is bad for
// performance. At the moment, we have no mechanism to prevent this from happening.

// reach package internals via package name
//
// [root] -> [pop "GUARD:PKG"] -> [pop pkg_name]* -> [push pkg_internal_name]
Expand All @@ -112,7 +116,9 @@ impl FileAnalyzer for NpmPackageAnalyzer {
"exports_guard_pop",
);
replace_edge(graph, pkg_name_pop, exports_guard_pop, 1);
let main = NormalizedRelativePath::from_str(&npm_pkg.main)
let main = Some(npm_pkg.main)
.filter(|main| !main.is_empty())
.and_then(|main| NormalizedRelativePath::from_str(&main))
.map(|p| p.into_path_buf())
.unwrap_or(PathBuf::from("index"))
.with_extension("");
Expand Down
Loading

0 comments on commit 169c94f

Please sign in to comment.