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

WIP: Fixing repl #9912

Closed
wants to merge 4 commits into from
Closed

WIP: Fixing repl #9912

wants to merge 4 commits into from

Conversation

alshdavid
Copy link
Contributor

@alshdavid alshdavid commented Aug 14, 2024

There were two issues:

  • env.from_js_value() was failing at runtime for wasm builds (I'm not sure why atm)
    • Changed this from env.from_js_value to manually constructing the target struct
  • @parcel/node-resolver-core/ResolverBase had a conditional statement to select the old vs new resolver which was failing at runtime for wasm builds.
    • Changed this from a BaseResolver property to a getBaseResolver() function

use napi::Env;
use napi::JsObject;
use napi::JsUnknown;
use napi_derive::napi;

#[napi]
pub fn transform(opts: JsObject, env: Env) -> napi::Result<JsUnknown> {
let config: parcel_js_swc_core::Config = env.from_js_value(opts)?;
let config = parcel_js_swc_core::Config {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@devongovett Any idea on why from_js_value fails to deserialize the value for wasm but not napi? The error was expected $name, got -1.

Is it okay to commit manually constructing the struct like this rather than using serde?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we change things in Config since the repl broke?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to log the value getting passed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like that error comes from here: https://github.com/napi-rs/napi-rs/blob/8b6cc10d779f94601775910e90d22067987fb0f7/crates/napi/src/bindgen_runtime/js_values/arraybuffer.rs#L702

Could be due to the upgrade of napi-rs somehow being incompatible with napi-wasm. I will investigate.

@devongovett
Copy link
Member

Closing in favor of #9936.

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

Successfully merging this pull request may close these issues.

4 participants