pub async fn fetch_compiled_module(
    &self,
    module_specifier: ModuleSpecifier,
    _maybe_referrer: Option<ModuleSpecifier>,
  ) -> Result<CompiledModule, ErrBox> {
    let state1 = self.clone();
    let state2 = self.clone();
    let module_specifier = module_specifier.clone();

    let out = self
      .file_fetcher
      .fetch_cached_source_file(&module_specifier, Permissions::allow_all())
      .expect("Cached source file doesn't exist");

    // TODO(ry) Try to lift compile_lock as high up in the call stack for
    // sanity.
    let compile_lock = self.compile_lock.lock().await;

    // Check if we need to compile files
    let was_compiled = match out.media_type {
      msg::MediaType::TypeScript
      | msg::MediaType::TSX
      | msg::MediaType::JSX => true,
      msg::MediaType::JavaScript => self.ts_compiler.compile_js,
      _ => false,
    };

    let compiled_module = if was_compiled {
      state1.ts_compiler.get_compiled_module(&out.url)?
    } else {
      CompiledModule {
        code: String::from_utf8(out.source_code.clone())?,
        name: out.url.to_string(),
      }
    };

    drop(compile_lock);

    if let Some(ref lockfile) = state2.lockfile {
      let mut g = lockfile.lock().unwrap();
      if state2.flags.lock_write {
        g.insert(&out.url, out.source_code);
      } else {
        let check = match g.check(&out.url, out.source_code) {
          Err(e) => return Err(ErrBox::from(e)),
          Ok(v) => v,
        };
        if !check {
          eprintln!(
            "Subresource integrity check failed --lock={}\n{}",
            g.filename, compiled_module.name
          );
          std::process::exit(10);
        }
      }
    }
    Ok(compiled_module)
  }
// TODO(bartlomieju): this method doesn't need to be async anymore
/// This method is used after `prepare_module_load` finishes and EsIsolate
/// starts loading source and executing source code. This method shouldn't
/// perform any IO (besides $DENO_DIR) and only operate on sources collected
/// during `prepare_module_load`.
this method doesn't need to be async anymore
This method is used after `prepare_module_load` finishes and EsIsolate
starts loading source and executing source code. This method shouldn't
perform any IO (besides $DENO_DIR) and only operate on sources collected
during `prepare_module_load`.
this method doesn ' t need to be async anymore This method is used after ` prepare_module_load ` finishes and EsIsolate starts loading source and executing source code . This method shouldn ' t perform any IO ( besides $DENO_DIR ) and only operate on sources collected during ` prepare_module_load ` .
pub async fn fetch_compiled_module(
    &self,
    module_specifier: ModuleSpecifier,
    _maybe_referrer: Option<ModuleSpecifier>,
  ) -> Result<CompiledModule, ErrBox> {
    let state1 = self.clone();
    let state2 = self.clone();
    let module_specifier = module_specifier.clone();
    let out = self
      .file_fetcher
      .fetch_cached_source_file(&module_specifier, Permissions::allow_all())
      .expect("Cached source file doesn't exist");
    // TODO(ry) Try to lift compile_lock as high up in the call stack for
    // sanity.
    let compile_lock = self.compile_lock.lock().await;
    // Check if we need to compile files
    let was_compiled = match out.media_type {
      msg::MediaType::TypeScript
      | msg::MediaType::TSX
      | msg::MediaType::JSX => true,
      msg::MediaType::JavaScript => self.ts_compiler.compile_js,
      _ => false,
    };
    let compiled_module = if was_compiled {
      state1.ts_compiler.get_compiled_module(&out.url)?
    } else {
      CompiledModule {
        code: String::from_utf8(out.source_code.clone())?,
        name: out.url.to_string(),
      }
    };
    drop(compile_lock);
    if let Some(ref lockfile) = state2.lockfile {
      let mut g = lockfile.lock().unwrap();
      if state2.flags.lock_write {
        g.insert(&out.url, out.source_code);
      } else {
        let check = match g.check(&out.url, out.source_code) {
          Err(e) => return Err(ErrBox::from(e)),
          Ok(v) => v,
        };
        if !check {
          eprintln!(
            "Subresource integrity check failed --lock={}\n{}",
            g.filename, compiled_module.name
          );
          std::process::exit(10);
        }
      }
    }
    Ok(compiled_module)
  }
pub async fn fetch_compiled_module ( & self , module_specifier : ModuleSpecifier , _maybe_referrer : Option < ModuleSpecifier > , ) -> Result < CompiledModule , ErrBox > { let state1 = self . clone ( ) ; let state2 = self . clone ( ) ; let module_specifier = module_specifier . clone ( ) ; let out = self . file_fetcher . fetch_cached_source_file ( & module_specifier , Permissions :: allow_all ( ) ) . expect ( " " ) ; // TODO(ry) Try to lift compile_lock as high up in the call stack for // sanity. let compile_lock = self . compile_lock . lock ( ) . await ; // Check if we need to compile files let was_compiled = match out . media_type { msg :: MediaType :: TypeScript | msg :: MediaType :: TSX | msg :: MediaType :: JSX => true , msg :: MediaType :: JavaScript => self . ts_compiler . compile_js , _ => false , } ; let compiled_module = if was_compiled { state1 . ts_compiler . get_compiled_module ( & out . url ) ? } else { CompiledModule { code : String :: from_utf8 ( out . source_code . clone ( ) ) ? , name : out . url . to_string ( ) , } } ; drop ( compile_lock ) ; if let Some ( ref lockfile ) = state2 . lockfile { let mut g = lockfile . lock ( ) . unwrap ( ) ; if state2 . flags . lock_write { g . insert ( & out . url , out . source_code ) ; } else { let check = match g . check ( & out . url , out . source_code ) { Err ( e ) => return Err ( ErrBox :: from ( e ) ) , Ok ( v ) => v , } ; if ! check { eprintln ! ( " \n " g filename compiled_module name ) ; std :: process :: exit ( 10 ) ; } } } Ok ( compiled_module ) }
TODO(bartlomieju): this method doesn't need to be async anymore
This method is used after `prepare_module_load` finishes and EsIsolate
starts loading source and executing source code.
TODO ( bartlomieju ) : this method doesn ' t need to be async anymore This method is used after ` prepare_module_load ` finishes and EsIsolate starts loading source and executing source code .
&self
module_specifier
ModuleSpecifier
_maybe_referrer
Option<ModuleSpecifier>
&self
module_specifier
ModuleSpecifier
_maybe_referrer
Option<ModuleSpecifier>