denoland / denoland/roll-your-own-javascript-runtime
Incomplete code for registering an extension in tutorial
- Dominant language
- Rust
- Stars
- 350
- Forks
- 36
- PR merge metrics
- No merged PRs in 30d
Description
The blog post contains an incomplete code for registering an extension in the first part of the [Roll your own JavaScript runtime](https://deno.com/blog/roll-your-own-javascript-runtime) series. It is missing the part where the extension builder expects the extension name to be passed in as an argument to `builder`.
Following the tutorial to the letter results in a compilation error. This is part of the [Adding a basic filesystem API](https://deno.com/blog/roll-your-own-javascript-runtime#adding-a-basic-filesystem-api) section.
```diff
async fn run_js(file_path: &str) -> Result<(), AnyError> {
let main_module = deno_core::resolve_path(file_path)?;
- let runjs_extension = Extension::builder()
+ let runjs_extension = Extension::builder("runjs")
.ops(vec![
op_read_file::decl(),
op_write_file::decl(),
op_remove_file::decl(),
])
.build();
let mut js_runtime = deno_core::JsRuntime::new(deno_core::RuntimeOptions {
module_loader: Some(Rc::new(deno_core::FsModuleLoader)),
extensions: vec![runjs_extension],
..Default::default()
});
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.