Skip to content

Commit

Permalink
Update CONTRIBUTING.md
Browse files Browse the repository at this point in the history
  • Loading branch information
rscarson authored Jul 16, 2024
1 parent ffbc4e7 commit 5b00201
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,23 @@ For that reason, rustyscript provides these extensions pre-configured and initia

The process of adding an extension involves the following steps:

1- Find the extensions in [deno/ext](https://github.com/denoland/deno/tree/main/ext)
2- Note the dependencies in `lib.rs`, in the `deps` portion of the call to `deno_core::extension`
3- Add a new crate-feature for the extension in `Cargo.toml`
- It should be preceded with a comment linking the portion of the spec it implements (see the extensions's readme)
- It should begin with the extension's crate, which must be an optional dependency of rustyscript
- It should then list the rustyscript crate-features associated with each of the dependencies found in step 2
4- Add a new directory in `src/ext/extension_name`. It will contain `mod.rs` and `init_extension_name.js`
5- Navigate to [deno/runtime/js](https://github.com/denoland/deno/tree/main/runtime/js) and find all the places in global the extension is added
6- In `init_extension_name.js`, include -all- JS sources provided by the new extension, and add the relevant portions to global (see other exts for examples)
7- In `mod.rs`, create your `init_extension_name` extensions and provide the `extensions` and `snapshot_extensions` functions
8- If the extension requires configuration, add a feature-gated section to `ExtensionOptions`
- If only one field, add it directly to ExtensionOptions
- Otherwise add an options structure in `mod.rs` and reference that
1. Find the extensions in [deno/ext](https://github.com/denoland/deno/tree/main/ext)
2. Note the dependencies in `lib.rs`, in the `deps` portion of the call to `deno_core::extension`
3. Add a new crate-feature for the extension in `Cargo.toml`

- It should be preceded with a comment linking the portion of the spec it implements (see the extensions's readme)
- It should begin with the extension's crate, which must be an optional dependency of rustyscript
- It should then list the rustyscript crate-features associated with each of the dependencies found in step 2

4. Add a new directory in `src/ext/extension_name`. It will contain `mod.rs` and `init_extension_name.js`
5. Navigate to [deno/runtime/js](https://github.com/denoland/deno/tree/main/runtime/js) and find all the places in global the extension is added
6. In `init_extension_name.js`, include -all- JS sources provided by the new extension, and add the relevant portions to global (see other exts for examples)
7. In `mod.rs`, create your `init_extension_name` extensions and provide the `extensions` and `snapshot_extensions` functions
8. If the extension requires configuration, add a feature-gated section to `ExtensionOptions`

- If only one field, add it directly to ExtensionOptions
- Otherwise add an options structure in `mod.rs` and reference that
-
9- in `src/ext/mod.rs` add feature-gated imports, and add your extension to the extensions functions -BELOW- any of its dependencies
10- Add a section to the table in `lib.rs` for the new extension, and use `cargo rdme` to regenerate the readme

Expand All @@ -51,4 +55,4 @@ The deno extensions require extensive configuration on both the rust and JS side
can easily cause unpredictable issues

For that reason, rustyscript provides these extensions pre-configured and initialized to the user as crate-level features. Because we managed load-order
and dependencies between extensions, exposing these could be dangerous.
and dependencies between extensions, exposing these could be dangerous.

0 comments on commit 5b00201

Please sign in to comment.