Skip to content

Commit

Permalink
refactor: deno_graph 0.84
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret committed Oct 28, 2024
1 parent e6f7ea8 commit dfc2e59
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
12 changes: 6 additions & 6 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 = { version = "0.83.0", default-features = false }
deno_ast = { version = "0.42.0", features = ["transpiling"] }
deno_graph = { version = "0.84.0", default-features = false }
deno_ast = { version = "0.43.0", features = ["transpiling"] }
import_map = "0.20.0"
serde = "1"

Expand Down
16 changes: 9 additions & 7 deletions src/v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ use deno_ast::EmitOptions;
use deno_ast::ModuleSpecifier;
use deno_ast::SourceMapOption;
use deno_ast::TranspileOptions;
use deno_graph::CapturingModuleParser;
use deno_graph::CapturingEsParser;
use deno_graph::EsParser;
use deno_graph::ModuleGraph;
use deno_graph::ModuleParser;
use deno_graph::ParseOptions;
use deno_npm::resolution::SerializedNpmResolutionSnapshot;
use deno_npm::resolution::SerializedNpmResolutionSnapshotPackage;
Expand Down Expand Up @@ -279,7 +279,7 @@ impl<'a> EszipRelativeFileBaseUrl<'a> {

pub struct FromGraphOptions<'a> {
pub graph: ModuleGraph,
pub parser: CapturingModuleParser<'a>,
pub parser: CapturingEsParser<'a>,
pub transpile_options: TranspileOptions,
pub emit_options: EmitOptions,
/// Base to make all descendant file:/// modules relative to.
Expand Down Expand Up @@ -1294,7 +1294,7 @@ impl EszipV2 {
#[allow(clippy::too_many_arguments)]
fn visit_module<'a>(
graph: &'a ModuleGraph,
parser: CapturingModuleParser,
parser: CapturingEsParser,
transpile_options: &TranspileOptions,
emit_options: &EmitOptions,
modules: &mut LinkedHashMap<String, EszipV2Module>,
Expand Down Expand Up @@ -1347,7 +1347,7 @@ impl EszipV2 {
| deno_graph::MediaType::Tsx
| deno_graph::MediaType::Dts
| deno_graph::MediaType::Dmts => {
let parsed_source = parser.parse_module(ParseOptions {
let parsed_source = parser.parse_program(ParseOptions {
specifier: &module.specifier,
source: module.source.clone(),
media_type: module.media_type,
Expand All @@ -1367,8 +1367,10 @@ impl EszipV2 {
let emit = parsed_source
.transpile(transpile_options, &emit_options)?
.into_source();
source = emit.source.into();
source_map = Arc::from(emit.source_map.unwrap_or_default());
source = emit.text.into_bytes().into();
source_map = Arc::from(
emit.source_map.map(|s| s.into_bytes()).unwrap_or_default(),
);
}
_ => {
return Err(anyhow::anyhow!(
Expand Down

0 comments on commit dfc2e59

Please sign in to comment.