Skip to content

feat: asset info support symbol key#9871

Merged
SyMind merged 12 commits intomainfrom
refactor-asset-info
Apr 17, 2025
Merged

feat: asset info support symbol key#9871
SyMind merged 12 commits intomainfrom
refactor-asset-info

Conversation

@SyMind
Copy link
Copy Markdown
Member

@SyMind SyMind commented Apr 1, 2025

Summary

This PR introduces a smart pointer called BindingCell.

When the "napi" feature is disabled, Root uses the sys_binding module as a simple alias for Box.

When the "napi" feature is enabled, Root uses the napi_binding module:

  1. Root establishes a 1:1 relationship between a Rust instance and a JS Object.
  2. Root creates a JS Object only when converting a Rust instance to a JS object.
  3. The JS Object is hold a weak reference to the Rust instance. If the Rust instance is dropped,
    any attempt to access the JS Object will throw an exception indicating that the Rust instance has been dropped.
  4. Root holds a napi_ref to the JS Object but does not manage its lifecycle. Instead, the JS Object is associated
    with another JS object (e.g., a Compilation JS object), ensuring it is not garbage-collected during that entity’s lifecycle.

image

By establishing a 1:1 relationship between the Rust instance and the JS Object, we can easily retain the JS Object associated with AssetInfo at creation, thereby preserving all user-added data on the JS Object, including any data keyed by Symbols.

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@github-actions github-actions bot added team The issue/pr is created by the member of Rspack. release: feature release: feature related release(mr only) labels Apr 1, 2025
@netlify
Copy link
Copy Markdown

netlify bot commented Apr 1, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit bfa73a4
🔍 Latest deploy log https://app.netlify.com/sites/rspack/deploys/6800807c106ff20008a00b78

@SyMind SyMind force-pushed the refactor-asset-info branch 2 times, most recently from 77807c2 to d294b0e Compare April 2, 2025 02:43
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 2, 2025

CodSpeed Performance Report

Merging #9871 will not alter performance

Comparing refactor-asset-info (bfa73a4) with main (5a49a01)

Summary

✅ 11 untouched benchmarks

@SyMind SyMind force-pushed the refactor-asset-info branch 2 times, most recently from 4b01f56 to 8076d4a Compare April 2, 2025 03:27
@SyMind SyMind marked this pull request as ready for review April 2, 2025 03:33
@SyMind SyMind requested a review from LingyuCoder as a code owner April 2, 2025 03:33
@SyMind SyMind force-pushed the refactor-asset-info branch 3 times, most recently from b8e6510 to 70ad35a Compare April 2, 2025 04:37
@SyMind SyMind force-pushed the refactor-asset-info branch from 70ad35a to 7a03661 Compare April 2, 2025 04:40
@SyMind SyMind force-pushed the refactor-asset-info branch from 36838fe to ea61c14 Compare April 2, 2025 05:45
@SyMind SyMind requested a review from jerrykingxyz as a code owner April 2, 2025 06:00
@SyMind SyMind force-pushed the refactor-asset-info branch 3 times, most recently from f22eec6 to ea61c14 Compare April 2, 2025 07:10
@SyMind SyMind force-pushed the refactor-asset-info branch 7 times, most recently from 7f9b183 to c2c9a6e Compare April 2, 2025 09:52
@SyMind SyMind force-pushed the refactor-asset-info branch from c2c9a6e to 18c740e Compare April 2, 2025 09:54
@SyMind SyMind force-pushed the refactor-asset-info branch from 18c740e to c18236d Compare April 2, 2025 09:57
@SyMind SyMind force-pushed the refactor-asset-info branch 3 times, most recently from bfa49cb to 130f1a5 Compare April 14, 2025 07:20
@SyMind SyMind force-pushed the refactor-asset-info branch from 130f1a5 to 09a3dd0 Compare April 14, 2025 13:28
@quininer quininer self-requested a review April 17, 2025 08:32
@SyMind SyMind merged commit 688a3d5 into main Apr 17, 2025
27 checks passed
@SyMind SyMind deleted the refactor-asset-info branch April 17, 2025 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: feature release: feature related release(mr only) team The issue/pr is created by the member of Rspack.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants