1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-25 15:29:32 -05:00

refactor: don't spin up V8 for deno cache (#8186)

This commit is contained in:
Luca Casonato 2020-10-29 14:19:55 +01:00 committed by GitHub
parent b0482400c9
commit 8d99adb6c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -242,16 +242,19 @@ async fn cache_command(
flags: Flags,
files: Vec<String>,
) -> Result<(), AnyError> {
let main_module =
ModuleSpecifier::resolve_url_or_path("./$deno$cache.ts").unwrap();
let program_state = ProgramState::new(flags)?;
let mut worker = MainWorker::new(&program_state, main_module.clone());
for file in files {
let specifier = ModuleSpecifier::resolve_url_or_path(&file)?;
// TODO(bartlomieju): don't use `preload_module` in favor of calling "ProgramState::prepare_module_load()"
// explicitly? Seems wasteful to create multiple worker just to run TS compiler
worker.preload_module(&specifier).await.map(|_| ())?;
program_state
.prepare_module_load(
specifier,
tsc::TargetLib::Main,
Permissions::allow_all(),
false,
program_state.maybe_import_map.clone(),
)
.await?;
}
Ok(())