Skip to content

nerdlabs/babel-plugin-transform-react-router-optimize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Commitizen friendly

babel-plugin-transform-react-router-optimize

The React Router library exposes all methods on the top level import, but allows developers to use imports referencing files directly inside /lib, which can result in smaller bundle sizes as it doesn't import all of the Router's dependencies.

See here for more information: Minimizing Bundle Size.

This plugin can be added to your .babelrc file and automatically transform ES2015 imports to their size optimized counterpart.

Example

In

import { Route, IndexRoute } from 'react-router';

Out

import Route from 'react-router/lib/Route';
import IndexRoute from 'react-router/lib/IndexRoute';

Installation

Note This plugin is built for babel 6 and does not work with babel 5.

npm install --save-dev babel-plugin-transform-react-router-optimize

Usage

Via .babelrc (recommended)

.babelrc

{
  "plugins": ["transform-react-router-optimize"]
}

Via CLI

babel --plugins transform-react-router-optimize script.js

Via Node API

require('babel-core').transform('code', {
    plugins: ['transform-react-router-optimize']
});

License

MIT

About

Babel plugin to optimize the bundle size of projects using react-router.

Resources

License

Stars

Watchers

Forks

Packages

No packages published