A Babel plugin that automatically rewrites ES2015 imports from 'react-router' (v2/v3) to direct file imports under '/lib', enabling bundle size optimization by cherry-picking only the used components. Stable at v1.0.2, released September 2017. Requires react-router >=2.0.0. Designed for Babel 6, not compatible with Babel 5. Key differentiator: eliminates manual import rewriting for React Router bundle optimization.
npm install babel-plugin-transform-react-router-optimizeVerified import paths — ran on the pinned version, not inferred.
Shows .babelrc config and transformation from top-level import to per-file imports for smaller bundles.
Upgrade to Babel 6 or use a different plugin for Babel 7 (e.g., transform-imports).
Use ES2016 import syntax for react-router imports.
Ensure you import from 'react-router' top-level, not subpaths.
For react-router v4+, use tree-shaking with webpack or babel-plugin-transform-imports.
Add "presets": ["es2015"] to .babelrc or install babel-preset-es2015.
Use react-router v2 or v3, or switch to a different optimization approach.
Ensure your build pipeline uses Babel with appropriate presets (es2015 or env).