Skip to content

perf: upgrade napi and remove compat mode - #14643

Closed
intellild wants to merge 1 commit into
mainfrom
perf/remove-napi-compat-mode
Closed

intellild wants to merge 1 commit into
mainfrom
perf/remove-napi-compat-mode

Conversation

@intellild

@intellild intellild commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

What Changed

  • Removed compat-mode from the napi-related Rust dependencies.
  • Moved module-facing JS accessors from handwritten raw N-API callbacks to #[napi] getters/setters for Module, NormalModule, ExternalModule, and derived module wrappers.
  • Preserved existing JS object shape by copying prototype accessor descriptors onto module instances, so Object.hasOwn(...) behavior remains unchanged.
  • Marked the new macro accessors as skip_typescript, keeping the public TypeScript API owned by banner.d.ts and avoiding generated duplicate declarations.
  • Replaced the revoked-module cleanup raw callback with create_function_from_closure.
  • Moved ThreadsafeJsValueRef off the compat-only napi::Ref path.

Why This Should Help

The previous module binding path generated a lot of repeated raw callback glue and per-module property setup. Module instances can be high-cardinality objects in loader/plugin hooks, so repeated accessor definitions and generic callback adapters are a poor place to spend binary size.

This keeps the JS-facing API stable while shifting the runtime accessors to napi-rs macro-generated registration and shared Rust helper methods. The remaining per-instance work is mainly descriptor copying for compatibility and the module identifier symbol.

Expected Benefit

  • Less handwritten N-API callback glue in rspack_binding_api.
  • Fewer duplicated accessor implementations across module wrapper types.
  • Smaller node binding surface from removing compat-mode support paths, while preserving the generated napi-binding.d.ts shape.

by OpenAI Codex

@github-actions

github-actions Bot commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

📦 Binary Size-limit

Comparing e8e71b3 to fix(css): dedupe link HMR stylesheets (#14666) by AsyncIter

❌ Size increased by 15.94KB from 66.74MB to 66.76MB (⬆️0.02%)

@codspeed

codspeed Bot commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 43 untouched benchmarks
⏩ 47 skipped benchmarks1


Comparing perf/remove-napi-compat-mode (e8e71b3) with main (32248d8)

Open in CodSpeed

Footnotes

  1. 47 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. ↩

@intellild
intellild force-pushed the perf/remove-napi-compat-mode branch from 5cc5628 to 471dbf2 Compare July 1, 2026 04:46
@intellild intellild changed the title perf: remove napi compat mode perf: upgrade napi and remove compat mode Jul 2, 2026
@intellild
intellild force-pushed the perf/remove-napi-compat-mode branch from 95b1c04 to ad4db1c Compare July 3, 2026 16:28
@intellild intellild closed this Jul 6, 2026
@intellild intellild reopened this Jul 6, 2026
@intellild
intellild force-pushed the perf/remove-napi-compat-mode branch from ad4db1c to e8e71b3 Compare July 6, 2026 05:54
@intellild intellild closed this Jul 31, 2026
@intellild
intellild deleted the perf/remove-napi-compat-mode branch July 31, 2026 02:34
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.

1 participant