I am currently trying to make use of Deno's native plugin API, and I've been having a hard time trying to gather the basic resources for plugin development. For the record, I've taken a look at a few implementations alongside the associated files with lib.rs found in libdeno.
Is there any documentation for plugin development in Deno? If not, can we look into making one? If there does exist a solution, I'd be willing to migrate from the horrors of Node Addons. What I'm primary looking for is a:
install
deno install \
--allow-env \
--allow-read \
--allow-write \
--name=create-deno-plugin \
https://denopkg.com/chiefbiiko/[email protected]/main.ts
usage
create-deno-plugin --async ./my-plugin
cd ./my-plugin
cargo build
deno test --allow-plugin --unstable
fs:
|-- my-plugin
| |-- .gitignore
| |-- Cargo.toml
| |-- src
| | |-- lib.rs
| |-- mod.js
| |-- test.js
Wow, it seems like create-deno-plugin can scaffold a Deno plugin exactly how I needed it. Does rusty_v8 get built with the plugin (as part of a transitive dependency by deno_core)?
I'd really make use of some docs or even some more examples for guidance. cc @ry @piscisaureus
@undefinedbuddy
yes, rusty_v8 is part of the build
also, if ur wondering about plugin distribution, have a look at
this release workflow prebuilding for the big3 and
this little script pulling in those prebuilts for library consumers
@chiefbiiko Thanks! This really helped a lot.
I updated to v1.0.0-rc and it seems like Deno.Plugin has been removed from the global Deno namespace, alongside openPlugin. Is there anywhere I can track new API changes besides the changelog for this version? Any migration guide?
@undefinedbuddy use --unstable flag to use plugins. Documented here https://doc.deno.land/https/raw.githubusercontent.com/denoland/deno/master/cli/js/lib.deno.unstable.d.ts
@ry Great! Does that mean in my type definitions I can just use Deno.Plugin, as in, is it available in the global Deno namespace after running with --unstable? Additionally, I lost track of the previous version I had installed and with this new update (v1.0.0-rc), I'm now experiencing errors in using certain APIs from std/fs.
I am currently trying to make use of Deno's native plugin API, and I've been having a hard time trying to gather the basic resources for plugin development. For the record, I've taken a look at a few implementations alongside the associated files with
lib.rsfound inlibdeno.Is there any documentation for plugin development in Deno? If not, can we look into making one? If there does exist a solution, I'd be willing to migrate from the horrors of Node Addons. What I'm primary looking for is a:
- Smooth development process and fluid production build release
- Method to compile plugin with TypeScript as single executable
@undefinedbuddy I've also faced same issues, spent whole weekend trying to figure out how native plugin system works, I think I can also provide a hand for making docs for this beast. Although the feature is in its earliest stage, even minimal documentation can help improving plugin support in general. Unfortunately https://doc.deno.land/https/raw.githubusercontent.com/denoland/deno/master/cli/js/lib.deno.unstable.d.ts refers only to Deno.openPlugin. I didn't found any declarations of Deno.core.ops Deno.core.dispatch so typescript seems not a first class citizen for plugin system yet.
@lu4 I created deno.core.d.ts in my project. Content below
declare namespace Deno {
export const core: {
ops(): { [key: string]: number };
dispatch(opId: number, control: Uint8Array, zeroCopy?: Uint8Array): ArrayBufferView | ArrayBuffer | undefined;
setAsyncHandler(opId: number, cb: (response: ArrayBufferView | ArrayBuffer | undefined) => void): void;
}
}
And in the beginning of the mod.ts I added /// <reference path="./deno.core.d.ts" /> and it works.
@shaunxu Thank you for provided .d.ts file, I was mentioning it to figure out a reason why the subject APIs were missing in deno itself, and whether the helping hand is necessary. But thank you for the effort!
For whom this might be useful: https://deno.land/manual/getting_started/typescript
@chiefbiiko Is your project create-deno-plugin still active? Or would you recommend using something like deno-plugin-prepare?
@ry Is there any info you give me, if you guys plan any kind of doc how to implement a deno native plugin? Or is there already something I didn't find, yet?
Thanks for your help, guys!
@mknet i haven#t used create-deno-plugin with a recent deno
anways, it used to provide necessary and functioning boilerplate for intersecting deno and rust
i think deno-plugin-prepare helps in running native plugins but not building them
released [email protected] which runs with the current deno v1.5.2
Most helpful comment
released
[email protected]which runs with the currentdeno v1.5.2