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

Public rust crate for Parcel API and moving napi bindings to node_bindings #9727

Merged
merged 2 commits into from
May 24, 2024

Conversation

alshdavid
Copy link
Contributor

In this PR I move the napi bindings out of the parcel_core package, the idea is the parcel_core package will be agnostic to the caller context where context specific behaviour would be consumed by the core abstracted behind traits (like Resolver, etc).

Test instructions

yarn build-native-release

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So the idea is:

cargo add parcel_core

Which is eventually used something like

use parcel_core::Parcel;
use parcel_core::ParcelOptions;
use parcel_core::ParcelRunOptions;

fn main() {
  let parcel = Parcel::new(ParcelOptions { /* ... */ });

  let report = parcel.run(ParcelRunOptions {  /* ... */  });
  println!("{:#?}", report);
}

For Napi bindings:

use parcel_core::Parcel;
use parcel_core::ParcelOptions;
use parcel_core::ParcelRunOptions;
use parcel_napi::ParcelNapiConnector;

#[napi]
fn main() {
  let parcel_napi = ParcelNapiConnector::new();
  // napi glue code

  let parcel = Parcel::new(ParcelOptions { 
    plugin_connectors: vec![parcel_napi],
  });

  let report = parcel.run(ParcelRunOptions {  /* ... */  });
  println!("{:#?}", report);
}

@alshdavid alshdavid added this pull request to the merge queue May 24, 2024
Merged via the queue into v2 with commit 38635b5 May 24, 2024
16 of 17 checks passed
@mischnic mischnic deleted the alsh/public-rust-api-todo branch May 28, 2024 11:37
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.

None yet

2 participants