Skip to content
This repository was archived by the owner on Mar 19, 2026. It is now read-only.

feat(native-plugin): fallback to js alias plugin when alias entries include customResolver#280

Merged
sapphi-red merged 1 commit intorolldown-vitefrom
06-22-feat/fallback-to-aliasPlugin-when-alias-entries-include-customResolver
Jun 23, 2025
Merged

feat(native-plugin): fallback to js alias plugin when alias entries include customResolver#280
sapphi-red merged 1 commit intorolldown-vitefrom
06-22-feat/fallback-to-aliasPlugin-when-alias-entries-include-customResolver

Conversation

@shulaoda
Copy link
Copy Markdown
Member

Description

Native alias plugin currently do not support customResolver, this is being tracked in rolldown/rolldown#4973.

@shulaoda shulaoda requested a review from sapphi-red June 22, 2025 12:09
@sapphi-red sapphi-red changed the title feat: fallback to js alias plugin when alias entries include customResolver feat(native-plugin): fallback to js alias plugin when alias entries include customResolver Jun 23, 2025
@sapphi-red sapphi-red merged commit de9074c into rolldown-vite Jun 23, 2025
17 checks passed
@sapphi-red sapphi-red deleted the 06-22-feat/fallback-to-aliasPlugin-when-alias-entries-include-customResolver branch June 23, 2025 02:00
@sapphi-red
Copy link
Copy Markdown
Member

sapphi-red commented Jun 23, 2025

Regarding the perf concern, why would customResolver be slower than JS alias plugin? customResolver function will be only called if the id matches the alias, while the resolveId hook of the JS alias plugin will be called for every id resolution (unless Vite wraps it with withFilter). For that reason, I guess customResolver has less overhead.

@shulaoda
Copy link
Copy Markdown
Member Author

shulaoda commented Jun 23, 2025

Regarding the perf concern, why would customResolver be slower than JS alias plugin? customResolver function will be only called if the id matches the alias, while the resolveId hook of the JS alias plugin will be called for every id resolution (unless Vite wraps it with withFilter). For that reason, I guess customResolver has less overhead.

Yes, the performance difference may not be significant. I actually tried implementing it a few days ago. The main challenge right now is that Rolldown wraps all plugin hooks with a JS-side context. There's currently no good solution for standalone plugins — we might need to implement something like an applyToEnvironment function to handle this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants