-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
refactor: remove PermissionsContainer
in deno_runtime
#24119
refactor: remove PermissionsContainer
in deno_runtime
#24119
Conversation
let code_source = if let Some(result) = self | ||
.shared | ||
.npm_module_loader | ||
.load_if_in_npm_package(specifier, maybe_referrer, permissions) | ||
.load_if_in_npm_package(specifier, maybe_referrer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The permissions were only used for cjs resolution for loading a package.json, which was kind of useless.
path: &Path, | ||
api_name: Option<&str>, | ||
) -> Result<(), AnyError>; | ||
} | ||
|
||
pub(crate) struct AllowAllNodePermissions; | ||
pub struct AllowAllNodePermissions; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I exposed this because it's faster to use this trait than construct a new PermissionsContainer.
state.put(Rc::new(NodeResolver::new( | ||
fs, | ||
npm_resolver, | ||
))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has an internal in_npm_package_cache
that we can share across workers by passing the single instance into here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, but let's wait for a second pair of eyes from Divy
referrer, | ||
DEFAULT_CONDITIONS, | ||
mode, | ||
permissions, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure these were only used for package.json? I thought we used them when probing for various file extensions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It hasn't been from what I can tell, but even if it were I don't think we should bother permission checking that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Someday we'll start truly migrating perm checks to using deno_permissions
:)
Also removes permissions being passed in for node resolution. It was completely useless because we only checked it for reading package.json files, but Deno reading package.json files for resolution is perfectly fine. My guess is this is also a perf improvement because Deno is doing less work.
Also removes permissions being passed in for node resolution. It was completely useless because we only checked it for reading package.json files, but Deno reading package.json files for resolution is perfectly fine.
My guess is this is also a perf improvement because Deno is doing less work.