Embedding deno in rust #21524
Unanswered
nearest-river
asked this question in
Q&A
Replies: 2 comments 2 replies
-
using the file from the example and modifying it to use the runtime extensions, I sadly get an error :/ use std::path::Path;
use std::rc::Rc;
use deno_runtime::deno_core::error::AnyError;
use deno_runtime::deno_core::FsModuleLoader;
use deno_runtime::deno_core::ModuleSpecifier;
use deno_runtime::permissions::PermissionsContainer;
use deno_runtime::worker::MainWorker;
use deno_runtime::worker::WorkerOptions;
use deno_runtime::runtime;
#[tokio::main]
async fn main() -> Result<(), AnyError> {
let js_path = Path::new(env!("CARGO_MANIFEST_DIR")).join("tmp.js");
let main_module = ModuleSpecifier::from_file_path(js_path).unwrap();
let mut worker = MainWorker::bootstrap_from_options(
main_module.clone(),
PermissionsContainer::allow_all(),
WorkerOptions {
module_loader: Rc::new(FsModuleLoader),
extensions: vec![runtime::init_ops_and_esm()],
..Default::default()
},
);
worker.execute_main_module(&main_module).await?;
worker.run_event_loop(false).await?;
Ok(())
} [dependencies]
deno_core = "0.258.0"
deno_runtime = "0.144.0"
tokio = { version = "1.36.0", features = ["full"] } thread 'main' panicked at /home/thomas/.cargo/registry/src/index.crates.io-6f17d22bba15001f/deno_core-0.254.0/runtime/jsruntime.rs:943:8:
Failed to evaluate extension JS: Uncaught SyntaxError: Unexpected strict mode reserved word
at ext:runtime/01_version.ts:8:1
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Can I embed the whole
deno
runtime in a rust app?.. not onlydeno_core
which'll need all sorts of configurations like permission passing and things like command line arguments..NOTE: Making a build tool
Beta Was this translation helpful? Give feedback.
All reactions