Provide a general summary of the issue here
@react-aria/optimize-locales-plugin does its filtering inside resolveId, but Vite/Rollup/Rolldown can now skip many unnecessary hook calls entirely using hook filters.
Rolldown reported the plugin as a significant part of plugin time in one of my builds:
[PLUGIN_TIMINGS] Your build spent significant time in plugins. Here is a breakdown:
- locales-plugin (76%)
- vite:handlebars (12%)
- sentry-vite-plugin (6%)
See https://rolldown.rs/reference/InputOptions.checks#plugintimings for more details.
🤔 Expected Behavior?
locales-plugin should only enter its resolveId handler for locale-looking specifiers where it can actually do something useful.
😯 Current Behavior
resolveId is called broadly and then quickly returns for most imports:
if (!/[/\\](@react-stately|@react-aria|@react-spectrum|@adobe[/\\]react-spectrum|react-stately|react-aria|react-aria-components)[/\\]/.test(sourcePath) || options?.ssr) {
return;
}
The check is cheap, but the hook call itself is not free in Rolldown/Vite builds.
💁 Possible Solution
Use the object hook form supported by Vite/Rollup/Rolldown:
resolveId: {
filter: {
id: /[a-z]{2}-[A-Z]{2}/
},
handler(specifier, sourcePath, options) {
// existing logic
}
}
🔦 Context
Vite docs: https://vite.dev/guide/api-plugin#hook-filters
🖥️ Steps to Reproduce
- Build a Vite/Rolldown app using
@react-aria/optimize-locales-plugin.
- Enable plugin timing checks.
- Observe
locales-plugin taking a significant percentage of plugin time.
Version
2.0.0
What browsers are you seeing the problem on?
Other
If other, please specify.
not relevant
What operating system are you using?
not relevant
🧢 Your Company/Team
No response
🕷 Tracking Issue
No response
Provide a general summary of the issue here
@react-aria/optimize-locales-plugin does its filtering inside
resolveId, but Vite/Rollup/Rolldown can now skip many unnecessary hook calls entirely using hook filters.Rolldown reported the plugin as a significant part of plugin time in one of my builds:
🤔 Expected Behavior?
locales-pluginshould only enter itsresolveIdhandler for locale-looking specifiers where it can actually do something useful.😯 Current Behavior
resolveIdis called broadly and then quickly returns for most imports:The check is cheap, but the hook call itself is not free in Rolldown/Vite builds.
💁 Possible Solution
Use the object hook form supported by Vite/Rollup/Rolldown:
🔦 Context
Vite docs: https://vite.dev/guide/api-plugin#hook-filters
🖥️ Steps to Reproduce
@react-aria/optimize-locales-plugin.locales-plugintaking a significant percentage of plugin time.Version
2.0.0
What browsers are you seeing the problem on?
Other
If other, please specify.
not relevant
What operating system are you using?
not relevant
🧢 Your Company/Team
No response
🕷 Tracking Issue
No response