Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add combinatorial basic module loaders in boa_interop #3785

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

hansl
Copy link
Contributor

@hansl hansl commented Apr 3, 2024

These can be useful in general for creating chains of custom module loaders without much boilerplate.

/// This predicate will return an error if the specifier is relative but the referrer
/// does not have a path, or if the resolved path is outside `base`.
#[inline]
pub fn path_resolver(base: PathBuf) -> impl Fn(Option<&Path>, JsString) -> JsResult<JsString> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jedel1043 This function will fix the bug in the SimpleModuleLoader. I will move this code into the SimpleModuleLoader as a free function, and use that function here instead. It should make it easier.

I'll duplicate the tests as well.

These can be useful in general for creating chains of custom
module loaders without much boilerplate.
@hansl hansl marked this pull request as ready for review April 15, 2024 22:55
@hansl
Copy link
Contributor Author

hansl commented Apr 15, 2024

@jedel1043 This is ready to review when you're ready.

Comment on lines +20 to +21
// When resolving modules we need to clone the second loader.
second: Rc<Second>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought: Hmmm, I don't really like this because we already wrap MergeModuleLoader in an Rc. Maybe it's time to commit to the Rc wrapper and change the receiver of the ModuleLoader methods to Rc<Self>.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not actionable from your side, I'm just documenting my thoughts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would be solved rather elegantly if we could return a JsResult<Module> or similar from load_imported_module. But that's going to take a longer time and more refactoring than necessary.

Copy link

codecov bot commented Apr 15, 2024

Codecov Report

Attention: Patch coverage is 37.28814% with 37 lines in your changes are missing coverage. Please review.

Project coverage is 50.26%. Comparing base (6ddc2b4) to head (ba06dd0).
Report is 137 commits behind head on main.

Files Patch % Lines
core/interop/src/loaders/predicate.rs 48.88% 23 Missing ⚠️
core/interop/src/loaders/merge.rs 0.00% 14 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3785      +/-   ##
==========================================
+ Coverage   47.24%   50.26%   +3.02%     
==========================================
  Files         476      461      -15     
  Lines       46892    45025    -1867     
==========================================
+ Hits        22154    22634     +480     
+ Misses      24738    22391    -2347     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants