Skip to content

Comments

feat(binding-builder): support using custom binding#10857

Merged
h-a-n-a merged 7 commits intomainfrom
binding-builder
Jul 2, 2025
Merged

feat(binding-builder): support using custom binding#10857
h-a-n-a merged 7 commits intomainfrom
binding-builder

Conversation

@h-a-n-a
Copy link
Contributor

@h-a-n-a h-a-n-a commented Jul 1, 2025

Summary

This PR supports using custom binding with environment variable RSPACK_BINDING.
Path-to-binding is a path to the root of the binding package.

RSPACK_BINDING=path-to-binding

This is achieved by our already used ast-grep package to scan and replace the original content of module @rspack/binding and @rspack/binding/package.json.

In order to either use or test the new binding package (which contains support for custom plugin), this PR also adds support for exposing experiments.createNativePlugin which is an alias to the original plugin create and would throw error if there's any naming collision with the internal builtin plugins. createNativePlugin is used to create wrappers around native plugins:

const MyPlugin = createNativePlugin("MyPlugin", (options) => {
 return options;
});

new MyPlugin({
 foo: "bar"
}).apply(compiler);

Tests are now containing two parts, the original binding and the builder testing binding. The latter part is to test if rspck-binding-builder successfully extended all the exposed symbols and functionalities provided by crates/node_binding. In order to cover that part, tests are written in a mixed style with the original rspack tests. With test.filter.js, these tests are only enabled when running test:base-builder script in rspack-test-tools. I talked to @stormslowly about these changes to the workflows. Due to the complexity, I would separate the workflow change to a separate PR.

Related links

Checklist

  • Tests updated (or not required). Required, but to heavy to implement in the same PR.
  • Documentation updated (or not required).

@h-a-n-a h-a-n-a requested a review from jerrykingxyz as a code owner July 1, 2025 08:11
@netlify
Copy link

netlify bot commented Jul 1, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit 3477666
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/6863b44a84076b000877fcb1

@github-actions github-actions bot added the release: feature release: feature related release(mr only) label Jul 1, 2025
@h-a-n-a h-a-n-a force-pushed the binding-builder branch from 219b44e to 35718bb Compare July 1, 2025 08:18
@h-a-n-a h-a-n-a changed the title feat: support using custom binding feat(binding-builder): support using custom binding Jul 1, 2025
@h-a-n-a h-a-n-a force-pushed the binding-builder branch from 908b676 to 157d997 Compare July 1, 2025 08:41
@codspeed-hq
Copy link

codspeed-hq bot commented Jul 1, 2025

CodSpeed Performance Report

Merging #10857 will not alter performance

Comparing binding-builder (3477666) with main (fc9cb1e)

🎉 Hooray! codspeed-node just leveled up to 4.0.1!

A heads-up, this is a breaking change and it might affect your current performance baseline a bit. But here's the exciting part - it's packed with new, cool features and promises improved result stability 🥳!
Curious about what's new? Visit our releases page to delve into all the awesome details about this new version.

Summary

✅ 16 untouched benchmarks

@hardfist
Copy link
Contributor

hardfist commented Jul 1, 2025

@ityuany can you help explain your current workflow of integration and see whether this solution meets your needs

@h-a-n-a h-a-n-a enabled auto-merge (squash) July 2, 2025 05:40
@h-a-n-a h-a-n-a merged commit 96f74d1 into main Jul 2, 2025
60 of 62 checks passed
@h-a-n-a h-a-n-a deleted the binding-builder branch July 2, 2025 05:41
@ityuany
Copy link
Contributor

ityuany commented Jul 2, 2025

@ityuany can you help explain your current workflow of integration and see whether this solution meets your needs

https://github.com/sheinsight/spack

We are currently forking rspack to attempt customized feature development, and then releasing our own binding. In our internal framework, we forward requests to @rspack/binding to @shined/spack-binding by hijacking require.resolve.

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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants