Skip to content

fix: optimize-locales-plugin not tree-shaking react-aria and react-stately monopackage#10110

Closed
ashleyryan wants to merge 1 commit into
adobe:mainfrom
ashleyryan:main
Closed

fix: optimize-locales-plugin not tree-shaking react-aria and react-stately monopackage#10110
ashleyryan wants to merge 1 commit into
adobe:mainfrom
ashleyryan:main

Conversation

@ashleyryan
Copy link
Copy Markdown

Closes #10109

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

We applied the following patch to react-aria and noticed a 60kb improvement:


const fs = require('fs')
const path = require('path')

const pluginPath = path.join(__dirname, '..', 'node_modules', '@react-aria', 'optimize-locales-plugin', 'LocalesPlugin.js')

if (!fs.existsSync(pluginPath)) {
  console.warn('[patch] @react-aria/optimize-locales-plugin not found, skipping patch')
  process.exit(0)
}

const original = '/[/\\\\](@react-stately|@react-aria|@react-spectrum|react-aria-components)[/\\\\]/'
const patched = '/[/\\\\](@react-stately|@react-aria|@react-spectrum|react-aria-components|react-aria|react-stately)[/\\\\]/'

let content = fs.readFileSync(pluginPath, 'utf8')

if (content.includes(patched)) {
  console.log('[patch] @react-aria/optimize-locales-plugin already patched, skipping')
  process.exit(0)
}

if (!content.includes(original)) {
  console.warn('[patch] Expected pattern not found in LocalesPlugin.js — plugin may have been updated. Manual review needed.')
  process.exit(0)
}

content = content.replace(original, patched)
fs.writeFileSync(pluginPath, content, 'utf8')
console.log('[patch] @react-aria/optimize-locales-plugin patched for monopackage path support')

🧢 Your Project:

@snowystinger
Copy link
Copy Markdown
Member

snowystinger commented May 26, 2026

Both react-aria and react-stately have intl directories, so should be included
https://github.com/adobe/react-spectrum/tree/main/packages/react-aria/intl
https://github.com/adobe/react-spectrum/tree/main/packages/react-stately/intl

Thanks for reporting that and fixing it

@snowystinger
Copy link
Copy Markdown
Member

@snowystinger
Copy link
Copy Markdown
Member

closing in favor of #10111

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@react-aria/optimize-locales-plugin not removing locales after 4-14 release

2 participants