-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge all native Rust modules into one package (#9146)
- Loading branch information
1 parent
c98a4a0
commit 2792324
Showing
87 changed files
with
285 additions
and
711 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[target.wasm32-unknown-unknown] | ||
rustflags = ["-C", "link-arg=--export-table"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[package] | ||
authors = ["Devon Govett <[email protected]>"] | ||
name = "parcel-node-bindings" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[dependencies] | ||
napi = {version = "2.12.6", features = ["serde-json"]} | ||
napi-derive = "2.12.5" | ||
parcel-js-swc-core = { path = "../../packages/transformers/js/core" } | ||
parcel-resolver = { path = "../../packages/utils/node-resolver-rs" } | ||
dashmap = "5.4.0" | ||
xxhash-rust = { version = "0.8.2", features = ["xxh3"] } | ||
|
||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies] | ||
parcel-dev-dep-resolver = { path = "../../packages/utils/dev-dep-resolver" } | ||
oxipng = "8.0.0" | ||
mozjpeg-sys = "1.0.0" | ||
libc = "0.2" | ||
|
||
[target.'cfg(target_arch = "wasm32")'.dependencies] | ||
getrandom = { version = "0.2", features = ["custom"], default-features = false } | ||
|
||
[target.'cfg(target_os = "macos")'.dependencies] | ||
jemallocator = { version = "0.3.2", features = ["disable_initial_exec_tls"] } | ||
|
||
[target.'cfg(windows)'.dependencies] | ||
mimalloc = { version = "0.1.25", default-features = false } | ||
|
||
[build-dependencies] | ||
napi-build = "2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#[cfg(not(target_arch = "wasm32"))] | ||
extern crate napi_build; | ||
|
||
fn main() { | ||
#[cfg(not(target_arch = "wasm32"))] | ||
napi_build::setup(); | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#[cfg(target_arch = "wasm32")] | ||
use std::alloc::{alloc, Layout}; | ||
|
||
#[cfg(target_os = "macos")] | ||
#[global_allocator] | ||
static GLOBAL: jemallocator::Jemalloc = jemallocator::Jemalloc; | ||
|
||
#[cfg(windows)] | ||
#[global_allocator] | ||
static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc; | ||
|
||
#[cfg(not(target_arch = "wasm32"))] | ||
mod fs_search; | ||
mod hash; | ||
#[cfg(not(target_arch = "wasm32"))] | ||
mod image; | ||
mod resolver; | ||
mod transformer; | ||
|
||
#[cfg(target_arch = "wasm32")] | ||
#[no_mangle] | ||
pub extern "C" fn napi_wasm_malloc(size: usize) -> *mut u8 { | ||
let align = std::mem::align_of::<usize>(); | ||
if let Ok(layout) = Layout::from_size_align(size, align) { | ||
unsafe { | ||
if layout.size() > 0 { | ||
let ptr = alloc(layout); | ||
if !ptr.is_null() { | ||
return ptr; | ||
} | ||
} else { | ||
return align as *mut u8; | ||
} | ||
} | ||
} | ||
|
||
std::process::abort(); | ||
} | ||
|
||
#[cfg(target_arch = "wasm32")] | ||
mod wasm { | ||
use core::num::NonZeroU32; | ||
use getrandom::register_custom_getrandom; | ||
use getrandom::Error; | ||
|
||
// TODO | ||
pub fn always_fail(buf: &mut [u8]) -> Result<(), Error> { | ||
let code = NonZeroU32::new(Error::CUSTOM_START + 42).unwrap(); | ||
Err(Error::from(code)) | ||
} | ||
|
||
register_custom_getrandom!(always_fail); | ||
} |
Oops, something went wrong.