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

Incomplete code for registering an extension in tutorial #6

Open
thinkverse opened this issue Feb 16, 2023 · 2 comments
Open

Incomplete code for registering an extension in tutorial #6

thinkverse opened this issue Feb 16, 2023 · 2 comments

Comments

@thinkverse
Copy link

The blog post contains an incomplete code for registering an extension in the first part of the 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 section.

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()
    });
@thinkverse thinkverse changed the title Incomplete code for registering an extension Incomplete code for registering an extension in tutorial Feb 16, 2023
@thinkverse
Copy link
Author

thinkverse commented Feb 16, 2023

Found another issue, this time in the example.js for the Implementing fetch section. content results in a reference error since it's missing the variable declaration. It's added later in the TypeScript implementation.

console.log("Hello", "runjs!");
+ let content;
content = await runjs.fetch(
  "https://deno.land/[email protected]/examples/welcome.ts",
);
console.log("Content from fetch", content);

@kamiazya
Copy link

If you are modifying a blog post, you may want to modify #7 as well.

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

No branches or pull requests

2 participants