Repository navigation
feat(core): gate the #[napi] items and mimalloc behind a napi feature - #831
Merged
Merged
Conversation
napi-rs registers every #[napi] item of every linked crate into one module, so oxc-node's exports collide with oxc_transform_napi's when an embedder compiles both into one addon (#807). A default-on `napi` feature now gates every registration item, module_init, the async transform task, and mimalloc-safe: --no-default-features builds a plain library with zero __napi_register symbols, while the published package builds exactly as before. napi itself stays a dependency — Function, PromiseRaw and Either run through the core signatures — and the feature's doc spells out what an embedder forwards instead. CI checks the embed configuration and asserts the built rlib carries no registration symbols, since cargo check alone cannot catch an ungated #[napi] site. Refs #807
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the lighter variant of #807: hide the
#[napi]items (andmimalloc-safe) behind anapiCargo feature, so an embedder like Vite+ can link the crate as a library without its exports registering into the host addon's module.napiis on by default — the published@oxc-node/corepackage, itsnapi buildpipeline, and every test are unchanged.default-features = falsedrops all ~29#[napi]registrations (verified: 0__napi_register*symbols vs ~34 in the default build),module_init,transform_async/TransformTask, andmimalloc-safe(now optional) — covering the name collision and the allocator part of Vite+'s carried patch.napi/napi-derivestay as dependencies:Function,PromiseRaw,Either,Env, andLoadFnOutputare woven through the core signatures (create_resolve,load), so removing them would be the two-crate split the issue discusses instead. An embedder compiles against the same napi 3.x and writes its own thin#[napi]forwarders.detect_runtime_syntax(otherwiseusingstays lowered on Node ≥ 24) andinit_tracing(forOXC_LOG), reusesource()/source_map()forOutput, and not redeclare the#[napi(object)]interface names its own.d.tswould gain.CI
The Lint job now runs
cargo check --all-targets --no-default-features(with and withoutdefault_global_allocator) and — sincecargo checkcannot catch a leaked#[napi](it still compiles) — builds the rlib and asserts it contains no__napi_registersymbols.Test plan
cargo checkunder both configurations,cargo clippy --all-targets --all-features -D warnings,cargo test,pnpm test,vp checkall pass.llvm-nmon the embed rlib: 0__napi_registersymbols; default build unchanged at ~34;napi build --platformproduces the identical package.