Skip to content
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

Document native plugin development process in Deno #4964

Closed
ghost opened this issue Apr 28, 2020 · 15 comments
Closed

Document native plugin development process in Deno #4964

ghost opened this issue Apr 28, 2020 · 15 comments
Labels
cli related to cli/ dir docs

Comments

@ghost
Copy link

ghost commented Apr 28, 2020

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:

  • Smooth development process and fluid production build release
  • Method to compile plugin with TypeScript as single executable

Cf. deno-plugin-prepare, deno-webview.

@chiefbiiko
Copy link
Contributor

chiefbiiko commented Apr 29, 2020

create-deno-plugin

install

deno install \
  --allow-env \
  --allow-read \
  --allow-write \
  --name=create-deno-plugin \
  https://denopkg.com/chiefbiiko/create-deno-plugin@v0.3.0/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

@ghost
Copy link
Author

ghost commented Apr 29, 2020

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

@chiefbiiko
Copy link
Contributor

@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

@ghost
Copy link
Author

ghost commented Apr 30, 2020

@chiefbiiko Thanks! This really helped a lot.

@ghost
Copy link
Author

ghost commented May 6, 2020

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?

@ry
Copy link
Member

ry commented May 6, 2020

@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

@ghost
Copy link
Author

ghost commented May 6, 2020

@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.

@lu4
Copy link

lu4 commented May 18, 2020

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:

  • Smooth development process and fluid production build release
  • Method to compile plugin with TypeScript as single executable

Cf. deno-plugin-prepare, deno-webview.

@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.

@shaunxu
Copy link

shaunxu commented May 19, 2020

@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.

@lu4
Copy link

lu4 commented May 19, 2020

@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!

@lu4
Copy link

lu4 commented May 19, 2020

For whom this might be useful: https://deno.land/manual/getting_started/typescript

@bartlomieju bartlomieju added cli related to cli/ dir docs labels May 21, 2020
@mknet
Copy link

mknet commented Nov 7, 2020

@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!

@chiefbiiko
Copy link
Contributor

chiefbiiko commented Nov 11, 2020

@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

@chiefbiiko
Copy link
Contributor

released create-deno-plugin@v0.3.0 which runs with the current deno v1.5.2

@bartlomieju
Copy link
Member

With native plugins removal in #11152 this is no longer relevant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli related to cli/ dir docs
Projects
None yet
Development

No branches or pull requests

6 participants