async fn print_file_info(
  worker: &MainWorker,
  module_specifier: ModuleSpecifier,
) -> Result<(), ErrBox> {
  let global_state = worker.state.borrow().global_state.clone();

  let out = global_state
    .file_fetcher
    .fetch_source_file(&module_specifier, None, Permissions::allow_all())
    .await?;

  println!(
    "{} {}",
    colors::bold("local:".to_string()),
    out.filename.to_str().unwrap()
  );

  println!(
    "{} {}",
    colors::bold("type:".to_string()),
    msg::enum_name_media_type(out.media_type)
  );

  let module_specifier_ = module_specifier.clone();

  global_state
    .prepare_module_load(
      module_specifier_.clone(),
      None,
      TargetLib::Main,
      Permissions::allow_all(),
      false,
      global_state.maybe_import_map.clone(),
    )
    .await?;
  global_state
    .clone()
    .fetch_compiled_module(module_specifier_, None)
    .await?;

  if out.media_type == msg::MediaType::TypeScript
    || (out.media_type == msg::MediaType::JavaScript
      && global_state.ts_compiler.compile_js)
  {
    let compiled_source_file = global_state
      .ts_compiler
      .get_compiled_source_file(&out.url)
      .unwrap();

    println!(
      "{} {}",
      colors::bold("compiled:".to_string()),
      compiled_source_file.filename.to_str().unwrap(),
    );
  }

  if let Ok(source_map) = global_state
    .clone()
    .ts_compiler
    .get_source_map_file(&module_specifier)
  {
    println!(
      "{} {}",
      colors::bold("map:".to_string()),
      source_map.filename.to_str().unwrap()
    );
  }

  let es_state_rc = EsIsolate::state(&worker.isolate);
  let es_state = es_state_rc.borrow();

  if let Some(deps) = es_state.modules.deps(&module_specifier) {
    println!("{}{}", colors::bold("deps:\n".to_string()), deps.name);
    if let Some(ref depsdeps) = deps.deps {
      for d in depsdeps {
        println!("{}", d);
      }
    }
  } else {
    println!(
      "{} cannot retrieve full dependency graph",
      colors::bold("deps:".to_string()),
    );
  }

  Ok(())
}
// TODO(bartlomieju): this function de facto repeats
// whole compilation stack. Can this be done better somehow?
this function de facto repeats
whole compilation stack.
this function de facto repeats whole compilation stack .
async fn print_file_info(
  worker: &MainWorker,
  module_specifier: ModuleSpecifier,
) -> Result<(), ErrBox> {
  let global_state = worker.state.borrow().global_state.clone();
  let out = global_state
    .file_fetcher
    .fetch_source_file(&module_specifier, None, Permissions::allow_all())
    .await?;
  println!(
    "{} {}",
    colors::bold("local:".to_string()),
    out.filename.to_str().unwrap()
  );
  println!(
    "{} {}",
    colors::bold("type:".to_string()),
    msg::enum_name_media_type(out.media_type)
  );
  let module_specifier_ = module_specifier.clone();
  global_state
    .prepare_module_load(
      module_specifier_.clone(),
      None,
      TargetLib::Main,
      Permissions::allow_all(),
      false,
      global_state.maybe_import_map.clone(),
    )
    .await?;
  global_state
    .clone()
    .fetch_compiled_module(module_specifier_, None)
    .await?;
  if out.media_type == msg::MediaType::TypeScript
    || (out.media_type == msg::MediaType::JavaScript
      && global_state.ts_compiler.compile_js)
  {
    let compiled_source_file = global_state
      .ts_compiler
      .get_compiled_source_file(&out.url)
      .unwrap();
    println!(
      "{} {}",
      colors::bold("compiled:".to_string()),
      compiled_source_file.filename.to_str().unwrap(),
    );
  }
  if let Ok(source_map) = global_state
    .clone()
    .ts_compiler
    .get_source_map_file(&module_specifier)
  {
    println!(
      "{} {}",
      colors::bold("map:".to_string()),
      source_map.filename.to_str().unwrap()
    );
  }
  let es_state_rc = EsIsolate::state(&worker.isolate);
  let es_state = es_state_rc.borrow();
  if let Some(deps) = es_state.modules.deps(&module_specifier) {
    println!("{}{}", colors::bold("deps:\n".to_string()), deps.name);
    if let Some(ref depsdeps) = deps.deps {
      for d in depsdeps {
        println!("{}", d);
      }
    }
  } else {
    println!(
      "{} cannot retrieve full dependency graph",
      colors::bold("deps:".to_string()),
    );
  }
  Ok(())
}
async fn print_file_info ( worker : & MainWorker , module_specifier : ModuleSpecifier , ) -> Result < ( ) , ErrBox > { let global_state = worker . state . borrow ( ) . global_state . clone ( ) ; let out = global_state . file_fetcher . fetch_source_file ( & module_specifier , None , Permissions :: allow_all ( ) ) . await ? ; println ! ( " " colors bold ( " " to_string ( ) ) out filename to_str ( ) unwrap ( ) ) ; println ! ( " " colors bold ( " " to_string ( ) ) msg enum_name_media_type ( out media_type ) ) ; let module_specifier_ = module_specifier . clone ( ) ; global_state . prepare_module_load ( module_specifier_ . clone ( ) , None , TargetLib :: Main , Permissions :: allow_all ( ) , false , global_state . maybe_import_map . clone ( ) , ) . await ? ; global_state . clone ( ) . fetch_compiled_module ( module_specifier_ , None ) . await ? ; if out . media_type == msg :: MediaType :: TypeScript || ( out . media_type == msg :: MediaType :: JavaScript && global_state . ts_compiler . compile_js ) { let compiled_source_file = global_state . ts_compiler . get_compiled_source_file ( & out . url ) . unwrap ( ) ; println ! ( " " colors bold ( " " to_string ( ) ) compiled_source_file filename to_str ( ) unwrap ( ) ) ; } if let Ok ( source_map ) = global_state . clone ( ) . ts_compiler . get_source_map_file ( & module_specifier ) { println ! ( " " colors bold ( " " to_string ( ) ) source_map filename to_str ( ) unwrap ( ) ) ; } let es_state_rc = EsIsolate :: state ( & worker . isolate ) ; let es_state = es_state_rc . borrow ( ) ; if let Some ( deps ) = es_state . modules . deps ( & module_specifier ) { println ! ( " " colors bold ( " \n " to_string ( ) ) deps name ) ; if let Some ( ref depsdeps ) = deps . deps { for d in depsdeps { println ! ( " " d ) ; } } } else { println ! ( " " colors bold ( " " to_string ( ) ) ) ; } Ok ( ( ) ) }
TODO(bartlomieju): this function de facto repeats
whole compilation stack.
TODO ( bartlomieju ) : this function de facto repeats whole compilation stack .
worker
&MainWorker
module_specifier
ModuleSpecifier
worker
&MainWorker
module_specifier
ModuleSpecifier