Show some warnings only in dev environment
Closes https://github.com/adobe/react-spectrum/issues/2944
I've refined which warnings to display in production to reduce bundle sizes, focusing on critical areas: accessibility, component state changes, and number parsing/formatting. I welcome any feedback!
In the first commit, all warnings are suppressed in the production environment to make it easier to see the difference. Show some warnings only in dev environment
Subsequent commits retain messages necessary for production.
- Keep accessibility warnings in production
- Keep component state change warnings in production
- Keep number parsing and formatting warnings in production
✅ Pull Request Checklist:
- [x] 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).
- [x] 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:
Verify that in production builds, only critical warnings are displayed.
🧢 Your Project:
Thanks for creating this, we are definitely interested in getting something like this going. I can bring this up with the team to clarify the direction we want to go in.
My initial thought is that these won't make it into our production build with the current setup, ~so we may need to something like an isProduction() macro that evaluates to process.env.NODE_ENV === 'production'. I think we would need to upgrade Parcel first to do that.~ Edit: I guess it would still get removed as a macro.
note that this won't work without changes to parcel. by default environment variables will be replaced during the build of react-spectrum itself, meaning these would never make it into people's applications. that's why we haven't done this so far.
Thanks for the feedback. It seems like like we'll have to wait for the Parcel issue (#8025) to be resolved. I'm eager to continue working on this PR once we have a way forward.
Parcel issue has been resolved, and I've re-applied these changes in #7977.