Skip to content

Commit

Permalink
Apply review pt. 2
Browse files Browse the repository at this point in the history
  • Loading branch information
jedel1043 committed May 17, 2023
1 parent 7b6afe0 commit c6ab9ca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions boa_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ struct Opt {
module: bool,

/// Root path from where the module resolver will try to load the modules.
#[arg(long, default_value_os_t = PathBuf::from("."), requires = "mod")]
modpath: PathBuf,
#[arg(long, short = 'r', default_value_os_t = PathBuf::from("."), requires = "mod")]
root: PathBuf,
}

impl Opt {
Expand Down Expand Up @@ -345,7 +345,7 @@ fn main() -> Result<(), io::Error> {
let args = Opt::parse();

let queue: &dyn JobQueue = &Jobs::default();
let loader = &SimpleModuleLoader::new(&args.modpath)
let loader = &SimpleModuleLoader::new(&args.root)
.map_err(|e| io::Error::new(io::ErrorKind::Other, e.to_string()))?;
let dyn_loader: &dyn ModuleLoader = loader;
let mut context = ContextBuilder::new()
Expand Down
10 changes: 6 additions & 4 deletions boa_engine/src/module/mod.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
//! Boa's implementation of the ECMAScript's module system.
//!
//! This module contains the [`Module`] type, which represents an [**Abstract Module Record**][module].
//! This module contains the [`Module`] type, which represents an [**Abstract Module Record**][module],
//! a [`ModuleLoader`] trait for custom module loader implementations, and [`SimpleModuleLoader`],
//! the default `ModuleLoader` for [`Context`] which can be used for most simple usecases.
//!
//! Every module roughly follows the same lifecycle:
//! - Parse using [`Module::parse`].
//! - Load all its dependencies using [`Module::load`].
//! - Link its dependencies together using [`Module::link`].
//! - Evaluate the module and its dependencies using [`Module::evaluate`].
//!
//! Additionally, the [`ModuleLoader`] trait allows customizing the "load" step on the lifecycle
//! The [`ModuleLoader`] trait allows customizing the "load" step on the lifecycle
//! of a module, which allows doing things like fetching modules from urls, having multiple
//! "modpaths" from where to import modules, or using Rust futures to avoid blocking the main thread
//! on loads. There's a default [`SimpleModuleLoader`] implementation that just loads modules
//! relative to a root path, which should hopefully cover most simple usecases.
//! on loads.
//!
//! More information:
//! - [ECMAScript reference][spec]
Expand Down

0 comments on commit c6ab9ca

Please sign in to comment.