Skip to content

Commit

Permalink
Use direct import to react-router.
Browse files Browse the repository at this point in the history
Fix #5079.
  • Loading branch information
ruiaraujo committed Aug 1, 2017
1 parent 200f7cb commit 0b0f55f
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/react-router-dom/modules/BrowserRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import warning from 'warning'
import React from 'react'
import PropTypes from 'prop-types'
import createHistory from 'history/createBrowserHistory'
import { Router } from 'react-router'
import Router from './Router'

/**
* The public API for a <Router> that uses HTML5 history.
Expand Down
2 changes: 1 addition & 1 deletion packages/react-router-dom/modules/HashRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import warning from 'warning'
import React from 'react'
import PropTypes from 'prop-types'
import createHistory from 'history/createHashHistory'
import { Router } from 'react-router'
import Router from './Router'

/**
* The public API for a <Router> that uses window.location.hash.
Expand Down
4 changes: 3 additions & 1 deletion packages/react-router-dom/modules/MemoryRouter.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export { MemoryRouter as default } from 'react-router'
// Written in this round about way for babel-transform-imports
import { MemoryRouter } from 'react-router'
export default MemoryRouter
2 changes: 1 addition & 1 deletion packages/react-router-dom/modules/NavLink.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import PropTypes from 'prop-types'
import { Route } from 'react-router'
import Route from './Route'
import Link from './Link'

/**
Expand Down
4 changes: 3 additions & 1 deletion packages/react-router-dom/modules/Prompt.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export { Prompt as default } from 'react-router'
// Written in this round about way for babel-transform-imports
import { Prompt } from 'react-router'
export default Prompt
4 changes: 3 additions & 1 deletion packages/react-router-dom/modules/Redirect.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export { Redirect as default } from 'react-router'
// Written in this round about way for babel-transform-imports
import { Redirect } from 'react-router'
export default Redirect
4 changes: 3 additions & 1 deletion packages/react-router-dom/modules/Route.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export { Route as default } from 'react-router'
// Written in this round about way for babel-transform-imports
import { Route } from 'react-router'
export default Route
4 changes: 3 additions & 1 deletion packages/react-router-dom/modules/Router.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export { Router as default } from 'react-router'
// Written in this round about way for babel-transform-imports
import { Router } from 'react-router'
export default Router
4 changes: 3 additions & 1 deletion packages/react-router-dom/modules/StaticRouter.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export { StaticRouter as default } from 'react-router'
// Written in this round about way for babel-transform-imports
import { StaticRouter } from 'react-router'
export default StaticRouter
4 changes: 3 additions & 1 deletion packages/react-router-dom/modules/Switch.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export { Switch as default } from 'react-router'
// Written in this round about way for babel-transform-imports
import { Switch } from 'react-router'
export default Switch
4 changes: 3 additions & 1 deletion packages/react-router-dom/modules/matchPath.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export { matchPath as default } from 'react-router'
// Written in this round about way for babel-transform-imports
import { matchPath } from 'react-router'
export default matchPath
4 changes: 3 additions & 1 deletion packages/react-router-dom/modules/withRouter.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export { withRouter as default } from 'react-router'
// Written in this round about way for babel-transform-imports
import { withRouter } from 'react-router'
export default withRouter
1 change: 1 addition & 0 deletions packages/react-router-dom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"babel-eslint": "^6.0.4",
"babel-plugin-dev-expression": "^0.2.1",
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-transform-imports": "^1.2.0",
"babel-plugin-transform-react-remove-prop-types": "^0.2.11",
"babel-preset-es2015": "^6.14.0",
"babel-preset-react": "^6.5.0",
Expand Down
8 changes: 7 additions & 1 deletion packages/react-router-dom/tools/babel-preset.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
const BABEL_ENV = process.env.BABEL_ENV
const building = BABEL_ENV != undefined && BABEL_ENV !== 'cjs'
const transformImports = require('babel-plugin-transform-imports');

const plugins = []
const plugins = [
[transformImports, {
'react-router': {
transform: building ? "react-router/es/${member}" : "react-router/${member}",
preventFullImport: true
}}]]

if (BABEL_ENV === 'umd') {
plugins.push('external-helpers')
Expand Down

0 comments on commit 0b0f55f

Please sign in to comment.