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

Refactoring for custom module loader support #1731

Merged

Conversation

tomatosalat0
Copy link
Contributor

Motivation

To support fully custom IModuleLoader implementations, some code from the abstract ModuleLoader class has been moved into the public static ModuleFactory class.

With these public methods, custom IModuleLoader implementations can be created and used without deriving from the abstract class ModuleLoader. This allows custom code to implement certain features like a cache for parsed Esprima.Ast.Module instances which can be shared across multiple engine instances. The additional methods allow to use a different source specifier for modules instead of the default Uri.LocalPath variant used by the default implementation.

The behavior of the existing DefaultModuleLoader has not been changed.

Implementation

The static class allows to create Jint.Runtime.Modules.Module instances without publishing the actual implementations like SourceTextModule or SyntheticModule, so these implementations can still be changed without affecting the public API.

Copy link
Collaborator

@lahma lahma left a comment

Choose a reason for hiding this comment

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

Splendid work, thank you for improving the public API promise and tweaking the logic!

@lahma lahma merged commit 8000a7f into sebastienros:main Jan 8, 2024
3 checks passed
@tomatosalat0 tomatosalat0 deleted the refactor-for-custom-module-loader branch January 8, 2024 20:57
@sebastienros
Copy link
Owner

Looks like the project got itself a new MVP. Thanks @tomatosalat0 for you recent PRs!

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

3 participants