diff --git a/boa_cli/src/main.rs b/boa_cli/src/main.rs index 37b42d9cc15..8950db512c6 100644 --- a/boa_cli/src/main.rs +++ b/boa_cli/src/main.rs @@ -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 { @@ -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() diff --git a/boa_engine/src/module/mod.rs b/boa_engine/src/module/mod.rs index a9afa449ab8..b7b38c854f5 100644 --- a/boa_engine/src/module/mod.rs +++ b/boa_engine/src/module/mod.rs @@ -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]