From fdcc78500cc1aff8c87d76abd1692e79977ac9cc Mon Sep 17 00:00:00 2001 From: Kitson Kelly Date: Mon, 2 Nov 2020 13:51:56 +1100 Subject: refactor(cli): migrate runtime compile/bundle to new infrastructure (#8192) Fixes #8060 --- cli/module_loader.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'cli/module_loader.rs') diff --git a/cli/module_loader.rs b/cli/module_loader.rs index 39690465c..b19476fe2 100644 --- a/cli/module_loader.rs +++ b/cli/module_loader.rs @@ -1,9 +1,9 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. use crate::import_map::ImportMap; +use crate::module_graph2::TypeLib; use crate::permissions::Permissions; use crate::program_state::ProgramState; -use crate::tsc::TargetLib; use deno_core::error::AnyError; use deno_core::futures::future::FutureExt; use deno_core::futures::Future; @@ -21,7 +21,7 @@ pub struct CliModuleLoader { /// When flags contains a `.import_map_path` option, the content of the /// import map file will be resolved and set. pub import_map: Option, - pub target_lib: TargetLib, + pub lib: TypeLib, pub is_main: bool, } @@ -29,7 +29,7 @@ impl CliModuleLoader { pub fn new(maybe_import_map: Option) -> Rc { Rc::new(CliModuleLoader { import_map: maybe_import_map, - target_lib: TargetLib::Main, + lib: TypeLib::DenoWindow, is_main: true, }) } @@ -37,7 +37,7 @@ impl CliModuleLoader { pub fn new_for_worker() -> Rc { Rc::new(CliModuleLoader { import_map: None, - target_lib: TargetLib::Worker, + lib: TypeLib::DenoWorker, is_main: false, }) } @@ -117,13 +117,21 @@ impl ModuleLoader for CliModuleLoader { is_dynamic: bool, ) -> Pin>>> { let specifier = specifier.clone(); - let target_lib = self.target_lib.clone(); let maybe_import_map = self.import_map.clone(); let state = op_state.borrow(); // The permissions that should be applied to any dynamically imported module let dynamic_permissions = state.borrow::().clone(); let program_state = state.borrow::>().clone(); + let lib = if program_state.flags.unstable { + if self.lib == TypeLib::DenoWindow { + TypeLib::UnstableDenoWindow + } else { + TypeLib::UnstableDenoWorker + } + } else { + self.lib.clone() + }; drop(state); // TODO(bartlomieju): `prepare_module_load` should take `load_id` param @@ -131,7 +139,7 @@ impl ModuleLoader for CliModuleLoader { program_state .prepare_module_load( specifier, - target_lib, + lib, dynamic_permissions, is_dynamic, maybe_import_map, -- cgit v1.2.3