rscarson / rustyscript

Effortless JS integration for rust
MIT License
175 stars 22 forks source link

Cannot import the re-exported op2 macro invocation #241

Open fdlange opened 2 hours ago

fdlange commented 2 hours ago

When trying out code similar to the "extensions" example provided with the crate to develop an external Rust extension

use rustyscript::deno_core::{extension, op2, OpState};
use rustyscript::deno_core::error::AnyError;

#[derive(Debug, Clone)]
pub struct WebConnectors{
}

#[op2(fast)]
#[bigint]
fn op_add_example(#[bigint] a: i64, #[bigint] b: i64) -> i64 {
    a + b
}

I receive the following compiler error:

error[E0433]: failed to resolve: use of undeclared crate or module deno_core --> labiroot/src/scripting/web_connector_ext.rs:19:1 | 19 | #[op2(async)] | ^^^^^^^^^^^^^ use of undeclared crate or module deno_core

This is very surprising, since all other items in the re-export (AnyError, OpState) etc are recognized and work well and my IDE can also locate the reexported op2 macro, but the compiler can't. I activated all features of Rustyscript to ensure it's not a feature issue, but this was unfortunately not fixing the problem. Is there a reasonable explanation for this, am I missing something here?

Thanks in advance, great crate!

utyfua commented 2 hours ago

Add deno_core to your Cargo.toml:

deno_core = "*"

Then import the macro

rscarson commented 2 hours ago

Add deno_core to your Cargo.toml:

deno_core = "*"

Then import the macro

Correct.

deno_core's macro body specifies ::deno_core, which requires callers to have deno_core as a direct dependency