-
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
Deno.openPlugin resolution is not inline with the rest of Deno #3448
Comments
It's not a JS module, module resolution is its own thing. While URL plugins are interesting 😄, I think it's properly consistent with other FS ops. I don't see why those shouldn't support the |
It is indeed not a JS module, but it is a module in the sense that you can use it to extend the funtionality of your programm - sort of like WASM. Also I don't think its really comparable to an fs op because its purpose is enirely different. It should fall inline with how imports work because thats what openPlugin does - it imports a plugin for use. I think it is important that URL plugins are a possibility, because otherwise it is very hard to disitribute them. The current way to make it work would be to manually fetch the plugin, store it in a temp dir - where we don't control the caching - and then pass the temp path into openPlugin. Very tedious. We solved this already with JS, TS, WASM, ect. so I would argue that the same should apply to plugins. On that note, if URL plugins are going to be a thing we might want to make |
And that sense isn't sufficiently close to language level. Can you think of anything which works relative to module location that doesn't contain the When you talk about it's purpose being similar to modules, that's in a really high level sense. What we're doing is reading a data file and creating some functions from it. |
I get what you mean. If openPlugin stays relative to cwd then that is fine I guess. You can always generate the relative path yourself with |
I don't see why we wouldn't use the same logic to resolve plugins as we would other resources. Supporting remote plugins though (via HTTP) I think is potentially a different thing. Even though they are different, having two different resolution schemes is fairly non-sensical. The only reason for it would be to confuse users. |
Resolving and loading plugins like modules would be nice, but there are some difficulties here. The underlying c function I have considered emulating the underlying function of Maybe a simpler approach here is to cache the plugin file like we do compiled JavaScript. Either way downloading a file and loading directly into memory as executable presents a lot of security concerns. A potential third approach of adding custom compiler support and building a custom cargo/rust compiler might be a good solution here as well. I like this solution the most, since a custom compiler could actually generate TypeScript bindings to go on top of said plugins. This also avoids downloading a compiled binary and loading directly to memory. When I first started working on plugins I thought that it would be cool if we could just import a The existing plugin system is intended to be very simple it's primary goal is to enable calling custom native code from the deno runtime. It's not a framework. Just a simple way to call into custom rust code. While I would like to be able to resolve plugins like imports it's not possible to determine the caller from the rust side like a referrer in a import resolution. For now I think the best we can really expect is some tooling in std to make this a little easier and maybe some tweaks to resolution to allow absolute full paths( |
I think we should go for the approach where we download into a folder in DENO_DIR and then also load them from there. I think manually loading the contents into memory, marking it as exec and directly calling the If we build remote resolution of plugins right into the 'secure' part of Deno then this makes the experience of using plugins simpler for users. We can use the same caching algorithms as JS imports, we can respect the I don't think there are any more security implications in running with |
I was against applying module semantics when plugins are brought in with a function call. Since this is maybe going in that direction, I'm perfectly okay with treating them as modules if they are actually brought in using the import syntax: |
We really don't even have a good way to resolve relative paths in function calls based on the "referrer" like we can with imports anyways, so current working directory is really the best we can do for now. Also the filename and extension for a plugin will vary for each os, so static imports are not really an option. I.E. |
Well you'd obviously resort to dynamic imports if you want compatibility :). Static imports are just that - an option - if you don't need this. If it fails you can throw a ^ This does sound like a way of introducing some bad practices. I'm also completely fine with the way it is now. That means no use of the |
@lucacasonato that is the eventual goal. In fact the original patches from @afinch7 were doing something along those lines IIRC. However we need some foundational infrastructure - having basic dlopen functionality is important and close to the OS. We will add sugar on top of that. |
I am currently trying to write a mongodb driver with
|
I don't think is Also, I support making |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Plugins are getting removed in 1.13 (#8490) so this issue is no longer relevant. |
In spirit this is still relevant. See #12943 for the follow up for FFI |
Just played around with the new modules and found some inconsistencies with the rest of Deno.
file://${path}
paths (resolves to${cwd}/file:/${path}
)http://
andhttps://
)The resolution algorithm that is used by import should probably also be used for plugins.
The text was updated successfully, but these errors were encountered: