diff --git a/CHANGELOG.md b/CHANGELOG.md index e1e53315..421f305a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ Enhancements ------------ * `is_empty` method is added to arrays, BLOB's, object maps, strings and ranges. +* `StaticModuleResolver` now stores the path in the module's `id` field. Version 1.9.0 diff --git a/src/api/compile.rs b/src/api/compile.rs index 73a3bf21..5322dbeb 100644 --- a/src/api/compile.rs +++ b/src/api/compile.rs @@ -113,7 +113,7 @@ impl Engine { }); } - let mut ast = self.compile_scripts_with_scope(scope, &[script])?; + let mut ast = self.compile_with_scope(scope, script)?; let mut resolver = StaticModuleResolver::new(); let mut imports = BTreeSet::new(); diff --git a/src/module/resolvers/stat.rs b/src/module/resolvers/stat.rs index b2d418c7..4019fc6d 100644 --- a/src/module/resolvers/stat.rs +++ b/src/module/resolvers/stat.rs @@ -54,8 +54,14 @@ impl StaticModuleResolver { /// Add a [module][Module] keyed by its path. #[inline] pub fn insert(&mut self, path: impl Into, mut module: Module) { + let path = path.into(); + + if module.id().is_none() { + module.set_id(path.clone()); + } + module.build_index(); - self.0.insert(path.into(), module.into()); + self.0.insert(path, module.into()); } /// Remove a [module][Module] given its path. #[inline(always)]