diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-02-14 00:43:53 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-14 00:43:53 +0100 |
commit | bd6ddd9b469b01b3663bbd275b7b11f7ac6e1ec2 (patch) | |
tree | 653285454e444f17b00f000c2e6c5bb72015c260 /core/modules.rs | |
parent | f917d2e2c10e0a94e564a9016217e7ce27c8bbee (diff) |
feat(core): allow to specify entry point for snapshotted ES modules (#17771)
This commit adds "ExtensionBuilder::esm_entry_point()" function that
allows to specify which of the extension files should be treated as an
entry point. If the entry point is not provided all modules are loaded
and evaluated, but if it is provided then only the entry point is explicitly
loaded and evaluated.
Co-authored-by: Leo Kettmeir <crowlkats@toaxl.com>
Diffstat (limited to 'core/modules.rs')
-rw-r--r-- | core/modules.rs | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/core/modules.rs b/core/modules.rs index b604e8c13..1f427508a 100644 --- a/core/modules.rs +++ b/core/modules.rs @@ -275,21 +275,27 @@ pub struct NoopModuleLoader; impl ModuleLoader for NoopModuleLoader { fn resolve( &self, - _specifier: &str, - _referrer: &str, + specifier: &str, + referrer: &str, _kind: ResolutionKind, ) -> Result<ModuleSpecifier, Error> { - Err(generic_error("Module loading is not supported")) + Err(generic_error( + format!("Module loading is not supported; attempted to resolve: \"{specifier}\" from \"{referrer}\"") + )) } fn load( &self, - _module_specifier: &ModuleSpecifier, - _maybe_referrer: Option<ModuleSpecifier>, + module_specifier: &ModuleSpecifier, + maybe_referrer: Option<ModuleSpecifier>, _is_dyn_import: bool, ) -> Pin<Box<ModuleSourceFuture>> { - async { Err(generic_error("Module loading is not supported")) } - .boxed_local() + let err = generic_error( + format!( + "Module loading is not supported; attempted to load: \"{module_specifier}\" from \"{maybe_referrer:?}\"", + ) + ); + async move { Err(err) }.boxed_local() } } @@ -2720,14 +2726,20 @@ if (import.meta.url != 'file:///main_with_code.js') throw Error(); .resolve("file://foo", "file://bar", ResolutionKind::Import) .err() .map(|e| e.to_string()), - Some("Module loading is not supported".to_string()) + Some( + "Module loading is not supported; attempted to resolve: \"file://foo\" from \"file://bar\"" + .to_string() + ) ); assert_eq!( loader .resolve("file://foo", "internal:bar", ResolutionKind::Import) .err() .map(|e| e.to_string()), - Some("Module loading is not supported".to_string()) + Some( + "Module loading is not supported; attempted to resolve: \"file://foo\" from \"internal:bar\"" + .to_string() + ) ); assert_eq!( resolve_helper( |