From 636352e0ca1e611c7673f2ab68538e1ddb2dc5b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Tue, 10 Jan 2023 14:35:44 +0100 Subject: fix(npm): allow to read package.json if permissions are granted (#17209) This commit changes signature of "deno_core::ModuleLoader::resolve" to pass an enum indicating whether or not we're resolving a specifier for dynamic import. Additionally "CliModuleLoader" was changes to store both "parent permissions" (or "root permissions") as well as "dynamic permissions" that allow to check for permissions in top-level module load an dynamic imports. Then all code paths that have anything to do with Node/npm compat are now checking for permissions which are passed from module loader instance associated with given worker. --- core/examples/ts_module_loader.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'core/examples') diff --git a/core/examples/ts_module_loader.rs b/core/examples/ts_module_loader.rs index d9b32d5be..c78c1f868 100644 --- a/core/examples/ts_module_loader.rs +++ b/core/examples/ts_module_loader.rs @@ -21,6 +21,7 @@ use deno_core::ModuleSource; use deno_core::ModuleSourceFuture; use deno_core::ModuleSpecifier; use deno_core::ModuleType; +use deno_core::ResolutionKind; use deno_core::RuntimeOptions; use futures::FutureExt; @@ -31,7 +32,7 @@ impl ModuleLoader for TypescriptModuleLoader { &self, specifier: &str, referrer: &str, - _is_main: bool, + _kind: ResolutionKind, ) -> Result { Ok(resolve_import(specifier, referrer)?) } -- cgit v1.2.3