Skip to content

Commit

Permalink
feat: add dt_route to link symbols to routes
Browse files Browse the repository at this point in the history
  • Loading branch information
wtlin1228 committed Oct 4, 2024
1 parent 20925de commit a0dea69
Show file tree
Hide file tree
Showing 8 changed files with 361 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target
/outputs
14 changes: 14 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ members = [
"crates/dt_parser",
"crates/dt_path_resolver",
"crates/dt_portable",
"crates/dt_route",
"crates/dt_scheduler",
"crates/dt_test_utils",
"crates/dt_tracker",
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ reexport all the library crates:
- parser
- path_resolver
- portable
- route
- scheduler
- tracker

Expand Down Expand Up @@ -151,6 +152,17 @@ let serialized = portable.export().unwrap();
let portable = Portable::import(serialized).unwrap();
```

### Route

`Route` gives you the relationship between routes and symbols.

```rs
let mut symbol_to_routes = SymbolToRoutes::new();
symbol_to_routes
.collect_route_dependency(&module_ast, &symbol_dependency)
.unwrap();
```

### Scheduler

`Scheduler` gives you the module path by topological order. It will check the wildcard exports and namespace imports. If A does wildcard exports or namespace imports from B, then B will be returned before A.
Expand Down
1 change: 1 addition & 0 deletions crates/dt_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ dt_i18n = { version = "0.1.0", path = "../dt_i18n" }
dt_parser = { version = "0.1.0", path = "../dt_parser" }
dt_path_resolver = { version = "0.1.0", path = "../dt_path_resolver" }
dt_portable = { version = "0.1.0", path = "../dt_portable" }
dt_route = { version = "0.1.0", path = "../dt_route" }
dt_scheduler = { version = "0.1.0", path = "../dt_scheduler" }
dt_tracker = { version = "0.1.0", path = "../dt_tracker" }
4 changes: 4 additions & 0 deletions crates/dt_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ pub mod portable {
pub use dt_portable::*;
}

pub mod route {
pub use dt_route::*;
}

pub mod scheduler {
pub use dt_scheduler::*;
}
Expand Down
17 changes: 17 additions & 0 deletions crates/dt_route/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
authors = ["Leo Lin <wtlin1228@gmail.com>"]
description = "find the relationship between symbols and routes"
edition = "2021"
name = "dt_route"
version = "0.1.0"


[dependencies]
anyhow = { workspace = true }
swc_core = { workspace = true }
swc_ecma_parser = { workspace = true }

dt_parser = { version = "0.1.0", path = "../dt_parser" }
dt_path_resolver = { version = "0.1.0", path = "../dt_path_resolver" }
dt_test_utils = { version = "0.1.0", path = "../dt_test_utils" }
dt_tracker = { version = "0.1.0", path = "../dt_tracker" }
Loading

0 comments on commit a0dea69

Please sign in to comment.