build(mwpw-177058): adds monitoring for a11y & 40% build reduction #302
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add react-axe for run-time accessibility auditing
Description
This change integrates
react-axeinto our React app so that during local development, every rendered component is automatically audited for common accessibility (a11y) issues. Instead of running separate CLI checks or waiting for a manual audit, violations (e.g., missing alt text, insufficient color contrast, or improper ARIA attributes) will be logged directly to the browser console the moment components mount or update.What's been added
A conditional block in our entry-point (usually
index.jsorApp.jsx) that only runs when:process.env.NODE_ENV !== 'production'typeof window !== 'undefined'(i.e., client-side)Inside that block:
Why this matters
Immediate feedback: Instead of discovering accessibility bugs during a late-stage QA pass or CI job, developers see them instantly while coding.
Stronger developer habits: By surfacing missing
aria-*attributes, unlabeled form controls, and other WCAG-related issues as warnings, engineers learn to build with semantic, accessible markup from day one.Zero impact on production: We only bundle
react-axein non-production builds. OnceNODE_ENV === 'production', the entire block is excluded, so end users don't incur any runtime overhead.How to verify
With your React dev server running (
npm run startor equivalent), open the browser consoleNavigate through the app and intentionally introduce an a11y issue (e.g., remove an
<img alt="…">or render a<button>without a label)Observe that violations appear in the console immediately, including:
Future Notes
If we upgrade to React 18+ and switch to the new
createRootAPI, we may consider adopting@axe-core/reactinstead, since it provides explicit support for concurrent rendering. For now,[email protected]works as expected in our dev environment.Demo