Skip to content

[node-resolve] Replace resolve and some rollup-baked exports fields handling with a Rust-based resolver #1874

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
SukkaW opened this issue May 30, 2025 · 2 comments

Comments

@SukkaW
Copy link
Contributor

SukkaW commented May 30, 2025

  • Rollup Plugin Name: @rollup/plugin-node-resolve
  • Rollup Plugin Version: 16.0.1

Feature Use Case

Currently, @rollup/plugin-node-resolve relies on resolve, a resolver created and maintained by Browserify, which hasn't been actively maintained and lacks the export map feature.

Rollup builds @rollup/plugin-node-resolve on top of resolve with extra code to handle the browser field and export map.

The resolve plugin is a hot path during the build process, ranging from 10 to thousands or even more. Rustifying the resolver could benefit performance.

Feature Proposal

Maybe Rollup could rustify the resolve part, starting with @rollup/plugin-node-resolve. It is possible to use a Rust-based resolver, like oxc-resolver or rspack-resolver directly. Rollup could also build a rollup-flavored one on top of those crates.

Also, those resolvers already support features (that resolve doesn't have) like export map and the browser field, so @rollup/plugin-node-resolve wouldn't need to re-implement those features again.

After experimenting with @rollup/plugin-node-resolve, we could then decide whether the Rollup core's built-in resolver can benefit from rustify as well.

@lukastaegert
Copy link
Member

I am not sure if it definitely needs to be "Rust" to improve performance, but I agree that completely owning the resolver will bring benefits. The greatest benefits I actually see from caching all directory accesses etc. during each build, something that currently is only done in the part handled by the old resolve plugin but not by the new parts.
But sure, it can also be Rust as long as jump between JavaScript and Rust does not become another bottleneck.
Unfortunately, I had little resources to pursue anything here, but I would be open if someone else picked it up.

@SukkaW
Copy link
Contributor Author

SukkaW commented Jun 1, 2025

The greatest benefits I actually see from caching all directory accesses etc. during each build

I see benefits from native exports and browser features, which are currently still maintained by rollup (which only adds burdens).

But sure, it can also be Rust as long as jump between JavaScript and Rust does not become another bottleneck.

webpack's enhanced-resolve could be the JavaScript alternative and is battle-tested. Also supports exports and browser by default.

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

No branches or pull requests

2 participants