Skip to content

perf(napi): remove napi_build::setup() from oxc_napi to avoid redundant rebuilds#20094

Merged
Boshen merged 1 commit intomainfrom
perf/remove-napi-build-rs
Mar 7, 2026
Merged

perf(napi): remove napi_build::setup() from oxc_napi to avoid redundant rebuilds#20094
Boshen merged 1 commit intomainfrom
perf/remove-napi-build-rs

Conversation

@Boshen
Copy link
Member

@Boshen Boshen commented Mar 7, 2026

Summary

  • Remove napi_build::setup() from crates/oxc_napi/build.rs (delete the file entirely) to prevent oxc_napi from being invalidated and recompiled on every sequential napi build invocation
  • napi_build::setup() registers cargo::rerun-if-env-changed=NAPI_TYPE_DEF_TMP_FOLDER, but @napi-rs/cli sets a different value for this env var per package, causing oxc_napi + all dependents to rebuild for each of the 5 NAPI packages
  • oxc_napi is a library crate — the linker args and env tracking are only needed in the leaf cdylib crates which already have their own build.rs

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings March 7, 2026 04:40
@github-actions github-actions bot added the C-performance Category - Solution not expected to change functional behavior, only performance label Mar 7, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR removes the napi_build::setup() build script from the shared oxc_napi crate to prevent unnecessary rebuild invalidation during sequential napi build runs, relying on the leaf NAPI cdylib crates’ existing build.rs setup instead.

Changes:

  • Deleted crates/oxc_napi/build.rs to stop tracking NAPI_TYPE_DEF_TMP_FOLDER at the shared-library level.
  • Removed napi-build from oxc_napi build-dependencies and from the crate’s published include list.
  • Updated Cargo.lock to drop the napi-build dependency from oxc_napi.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.

File Description
crates/oxc_napi/build.rs Removed build script to avoid env-driven rebuild invalidation.
crates/oxc_napi/Cargo.toml Dropped napi-build build-dependency and removed build.rs from include.
Cargo.lock Removed napi-build from oxc_napi dependency list.

@codspeed-hq
Copy link

codspeed-hq bot commented Mar 7, 2026

Merging this PR will not alter performance

✅ 53 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing perf/remove-napi-build-rs (bb2bd08) with main (b40fa52)2

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (2baa5fb) during the generation of this report, so b40fa52 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1607b1c430

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…undant rebuilds

`oxc_napi/build.rs` called `napi_build::setup()` which registers
`cargo::rerun-if-env-changed=NAPI_TYPE_DEF_TMP_FOLDER`. Since each
sequential `napi build` invocation sets a different value for this env
var, `oxc_napi` was invalidated and recompiled for every NAPI package.

`oxc_napi` is a library crate, not a cdylib entry point — the linker
args and env tracking from `napi_build::setup()` are only needed in
the leaf cdylib crates which already have their own `build.rs`.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Boshen Boshen force-pushed the perf/remove-napi-build-rs branch from 1607b1c to bb2bd08 Compare March 7, 2026 05:03
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bb2bd082a5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Boshen Boshen merged commit 4ea8f9a into main Mar 7, 2026
39 of 40 checks passed
@Boshen Boshen deleted the perf/remove-napi-build-rs branch March 7, 2026 05:27
camc314 pushed a commit that referenced this pull request Mar 9, 2026
### 🚀 Features

- e8547cc parser: Report error for using declarations in ambient
contexts (#19934) (camc314)
- 8345318 allocator: Add methods for boxed slices `ArenaBox<[T]>`
(#19968) (overlookmotel)
- f83be30 allocator: Add `Vec::push_fast` method (#19959)
(overlookmotel)

### 🐛 Bug Fixes

- 291d867 transformer_plugins: Unwrap ChainExpression after define
replacement removes optional markers (#20058) (IWANABETHATGUY)
- 36b2e56 codegen: Print type for TSImportEqualsDeclaration (#20128)
(camc314)
- 5a246ec codegen: Print type arguments for JSXOpeningElement (#20127)
(camc314)
- a40870e codegen: Preserve parens for TSNonNullExpression (#20125)
(camc314)
- ae830b2 codegen: Print `declare` for `TSInterfaceDeclaration` (#20124)
(camc314)
- 92cfb14 linter/plugins: Fix types for `walkProgram` and
`walkProgramWithCfg` (#20081) (overlookmotel)
- ee0491e apps,napi: Explicitly specify libs in tsconfigs (#20071)
(camc314)
- 588009e codegen: Print `static` keyword for TSIndexSignature (#19755)
(Dunqing)
- 5a8799c codegen: Print `with_clause` for `ExportNamedDeclaration`
(#20002) (Dunqing)
- 7502afe parser: Correct capacity for tokens `Vec` (#19967)
(overlookmotel)

### ⚡ Performance

- 4ea8f9a napi: Remove `napi_build::setup()` from `oxc_napi` to avoid
redundant rebuilds (#20094) (Boshen)
- 2baa5fb napi: Unify build-test profile to coverage for cache sharing
(#20090) (Boshen)
- 8ba61dd parser: Make pushing tokens faster (#19960) (overlookmotel)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
Boshen added a commit that referenced this pull request Mar 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-performance Category - Solution not expected to change functional behavior, only performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants