Skip to content

Commit

Permalink
Move all dependencies for v3 rust prototype behind a feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
devongovett committed Jul 21, 2024
1 parent f58a5e8 commit 4e21d2e
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 31 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 49 additions & 20 deletions crates/node-bindings/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,50 +8,79 @@ edition = "2021"
crate-type = ["cdylib"]

[features]
canary = ["sentry", "whoami", "rustls"]

canary = ["sentry", "whoami", "rustls", "v3-prototype"]
v3-prototype = [
"parcel",
"parcel_core",
"parcel_package_manager",
"parcel_plugin_transformer_js",
"parcel_napi_helpers",
"anyhow",
"glob",
"log",
"mockall",
"num_cpus",
"parking_lot",
"toml",
"tracing",
"tracing-appender",
"tracing-subscriber",
]
rustls = ["sentry/rustls"]
openssl = ["sentry/native-tls"]

[dependencies]
parcel = { path = "../parcel" }
parcel_core = { path = "../parcel_core" }
parcel = { path = "../parcel", optional = true }
parcel_core = { path = "../parcel_core", optional = true }
parcel-js-swc-core = { path = "../../packages/transformers/js/core" }
parcel-resolver = { path = "../../packages/utils/node-resolver-rs" }
parcel_package_manager = { path = "../parcel_package_manager" }
parcel_plugin_transformer_js = { path = "../parcel_plugin_transformer_js" }
parcel_napi_helpers = { path = "../parcel_napi_helpers" }
parcel_package_manager = { path = "../parcel_package_manager", optional = true }
parcel_plugin_transformer_js = { path = "../parcel_plugin_transformer_js", optional = true }
parcel_napi_helpers = { path = "../parcel_napi_helpers", optional = true }
parcel_filesystem = { path = "../parcel_filesystem" }

anyhow = "1.0.82"
anyhow = { version = "1.0.82", optional = true }
dashmap = "5.4.0"
glob = "0.3.1"
log = "0.4.21"
mockall = "0.12.1"
glob = { version = "0.3.1", optional = true }
log = { version = "0.4.21", optional = true }
mockall = { version = "0.12.1", optional = true }
napi-derive = "2.16.3"
num_cpus = "1.16.0"
parking_lot = "0.12"
num_cpus = { version = "1.16.0", optional = true }
parking_lot = { version = "0.12", optional = true }
serde = { version = "1.0.200", features = ["derive"] }
serde_json = "1.0.116"
toml = "0.8.12"
tracing = "0.1.40"
tracing-appender = "0.2.3"
tracing-subscriber = "0.3.18"
toml = { version = "0.8.12", optional = true }
tracing = { version = "0.1.40", optional = true }
tracing-appender = { version = "0.2.3", optional = true }
tracing-subscriber = { version = "0.3.18", optional = true }
xxhash-rust = { version = "0.8.2", features = ["xxh3"] }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
parcel = { path = "../parcel", features = ["nodejs"] }
parcel = { path = "../parcel", features = ["nodejs"], optional = true }
parcel-dev-dep-resolver = { path = "../../packages/utils/dev-dep-resolver" }
parcel-macros = { path = "../macros", features = ["napi"] }

crossbeam-channel = "0.5.6"
indexmap = "1.9.2"
libc = "0.2"
mozjpeg-sys = "1.0.0"
napi = { version = "2.16.4", features = ["async", "napi4", "napi5", "serde-json"] }
napi = { version = "2.16.4", features = [
"async",
"napi4",
"napi5",
"serde-json",
] }
once_cell = { version = "1.19.0" }
oxipng = "8.0.0"
rayon = "1.7.0"
sentry = { version = "0.32.2", optional = true, default-features = false, features = ["anyhow", "backtrace", "contexts", "debug-images", "panic", "reqwest"] }
sentry = { version = "0.32.2", optional = true, default-features = false, features = [
"anyhow",
"backtrace",
"contexts",
"debug-images",
"panic",
"reqwest",
] }
whoami = { version = "1.5.1", optional = true }

[target.'cfg(target_arch = "wasm32")'.dependencies]
Expand Down
5 changes: 3 additions & 2 deletions crates/node-bindings/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::alloc::alloc;
#[cfg(target_arch = "wasm32")]
use std::alloc::Layout;

#[cfg(feature = "sentry")]
mod init_sentry;

#[cfg(all(target_os = "macos", not(miri)))]
Expand All @@ -15,7 +16,7 @@ static GLOBAL: jemallocator::Jemalloc = jemallocator::Jemalloc;
#[global_allocator]
static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;

#[cfg(not(target_arch = "wasm32"))]
#[cfg(all(feature = "v3-prototype", not(target_arch = "wasm32")))]
mod file_system;

/// napi versions of `crate::core::requests`
Expand All @@ -25,7 +26,7 @@ mod hash;
#[cfg(not(target_arch = "wasm32"))]
mod image;

#[cfg(not(target_arch = "wasm32"))]
#[cfg(all(feature = "v3-prototype", not(target_arch = "wasm32")))]
mod parcel;
mod resolver;
mod transformer;
Expand Down
2 changes: 1 addition & 1 deletion crates/node-bindings/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use napi::JsUnknown;
use napi::Ref;
use napi::Result;
use napi_derive::napi;
use parcel::file_system::FileSystemRef;
use parcel_filesystem::FileSystemRef;
use parcel_resolver::ExportsCondition;
use parcel_resolver::Extensions;
use parcel_resolver::Fields;
Expand Down
14 changes: 7 additions & 7 deletions crates/node-bindings/src/transformer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ use napi::JsObject;
use napi::JsUnknown;
use napi_derive::napi;

use parcel_core::plugin::{
InitialAsset, RunTransformContext, TransformationInput, TransformerPlugin,
};
use parcel_plugin_transformer_js::ParcelJsTransformerPlugin;

use parcel_napi_helpers::anyhow_to_napi;

#[cfg(feature = "v3-prototype")]
#[napi]
pub fn _testing_run_parcel_js_transformer_plugin(
target_path: String,
env: Env,
) -> napi::Result<JsUnknown> {
use parcel_core::plugin::{
InitialAsset, RunTransformContext, TransformationInput, TransformerPlugin,
};
use parcel_napi_helpers::anyhow_to_napi;
use parcel_plugin_transformer_js::ParcelJsTransformerPlugin;

let mut transformer = ParcelJsTransformerPlugin::new();
let mut context = RunTransformContext::default();
let input = TransformationInput::InitialAsset(InitialAsset {
Expand Down
2 changes: 2 additions & 0 deletions packages/core/core/src/parcel-v3/ParcelV3.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export type ParcelV3Options = {|
export class ParcelV3 {
_internal: ParcelNapi;

static available: boolean = !!ParcelNapi;

constructor({
fs,
nodeWorkers,
Expand Down
4 changes: 4 additions & 0 deletions packages/core/integration-tests/test/parcel-v3.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import type {
} from '@parcel/types-internal';

describe('parcel-v3', function () {
if (!ParcelV3.available) {
return;
}

// Add to @parcel/utils later
function toFileSystemV3(fs: ClassicFileSystem): FileSystem {
return {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/rust/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"napi-wasm": "^1.0.1"
},
"scripts": {
"build": "napi build --platform --cargo-cwd ../../../crates/node-bindings",
"build": "napi build --platform --features canary --cargo-cwd ../../../crates/node-bindings",
"build-canary": "napi build --platform --profile canary --features canary --cargo-cwd ../../../crates/node-bindings",
"build-release": "napi build --platform --release --cargo-cwd ../../../crates/node-bindings",
"wasm:build": "cargo build -p parcel-node-bindings --target wasm32-unknown-unknown && cp ../../../target/wasm32-unknown-unknown/debug/parcel_node_bindings.wasm .",
Expand Down

0 comments on commit 4e21d2e

Please sign in to comment.