Skip to content

Commit

Permalink
feat: from_graph - ability to make file specifiers relative (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret committed Jun 25, 2024
1 parent ce93ccb commit e47e372
Show file tree
Hide file tree
Showing 7 changed files with 296 additions and 118 deletions.
37 changes: 19 additions & 18 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ license = "MIT"
members = ["lib"]

[workspace.dependencies]
deno_graph = "0.78.0"
import_map = "0.19.1"
deno_graph = "0.79.0"
import_map = "0.20.0"
serde = "1"

[profile.release]
Expand Down
11 changes: 6 additions & 5 deletions benches/source_hash_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,13 @@ async fn build_eszip(mb: usize) -> EszipV2 {
)
.await;
graph.valid().unwrap();
EszipV2::from_graph(
EszipV2::from_graph(eszip::FromGraphOptions {
graph,
&analyzer.as_capturing_parser(),
TranspileOptions::default(),
EmitOptions::default(),
)
parser: analyzer.as_capturing_parser(),
transpile_options: TranspileOptions::default(),
emit_options: EmitOptions::default(),
relative_file_base: None,
})
.unwrap()
}

Expand Down
13 changes: 7 additions & 6 deletions lib/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ pub async fn build_eszip(
specifier, content, ..
} => {
let import_map = import_map::parse_from_json_with_options(
&specifier,
specifier.clone(),
&String::from_utf8(content.to_vec()).unwrap(),
import_map::ImportMapOptions {
address_hook: None,
Expand Down Expand Up @@ -340,12 +340,13 @@ pub async fn build_eszip(
graph
.valid()
.map_err(|e| js_sys::Error::new(&e.to_string()))?;
let mut eszip = eszip::EszipV2::from_graph(
let mut eszip = eszip::EszipV2::from_graph(eszip::FromGraphOptions {
graph,
&analyzer.as_capturing_parser(),
Default::default(),
Default::default(),
)
parser: analyzer.as_capturing_parser(),
transpile_options: Default::default(),
emit_options: Default::default(),
relative_file_base: None,
})
.map_err(|e| js_sys::Error::new(&e.to_string()))?;
if let Some((import_map_specifier, import_map_content)) =
maybe_import_map_data
Expand Down
13 changes: 7 additions & 6 deletions src/examples/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async fn main() {
} => {
let content = String::from_utf8(content.to_vec()).unwrap();
let import_map =
import_map::parse_from_json(&specifier, &content).unwrap();
import_map::parse_from_json(specifier.clone(), &content).unwrap();
(Some(import_map.import_map), Some((specifier, content)))
}
_ => unimplemented!(),
Expand All @@ -70,12 +70,13 @@ async fn main() {

graph.valid().unwrap();

let mut eszip = eszip::EszipV2::from_graph(
let mut eszip = eszip::EszipV2::from_graph(eszip::FromGraphOptions {
graph,
&analyzer.as_capturing_parser(),
TranspileOptions::default(),
EmitOptions::default(),
)
parser: analyzer.as_capturing_parser(),
transpile_options: TranspileOptions::default(),
emit_options: EmitOptions::default(),
relative_file_base: None,
})
.unwrap();
if let Some((import_map_specifier, import_map_content)) =
maybe_import_map_data
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use v2::EszipV2Modules;
pub use crate::error::ParseError;
pub use crate::v1::EszipV1;
pub use crate::v2::EszipV2;
pub use crate::v2::FromGraphOptions;

pub use deno_ast;
pub use deno_graph;
Expand Down
Loading

0 comments on commit e47e372

Please sign in to comment.