Skip to content

Commit f9369d8

Browse files
billyjanitschmjackson
authored andcommitted
Add ES build to react-router and react-router-dom (#4432)
1 parent 85bb2b1 commit f9369d8

File tree

22 files changed

+50
-16
lines changed

22 files changed

+50
-16
lines changed

packages/react-router-dom/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
es
12
umd
23
node_modules
34
/*.js

packages/react-router-dom/modules/.babelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"presets": [
3-
[ "es2015", { "loose": true } ],
3+
"../tools/es2015Preset",
44
"stage-1",
55
"react"
66
],

packages/react-router-dom/modules/BrowserRouter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { PropTypes } from 'react'
22
import createHistory from 'history/createBrowserHistory'
3-
import Router from 'react-router/Router'
3+
import { Router } from 'react-router'
44

55
/**
66
* The public API for a <Router> that uses HTML5 history.

packages/react-router-dom/modules/HashRouter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { PropTypes } from 'react'
22
import createHistory from 'history/createHashHistory'
3-
import Router from 'react-router/Router'
3+
import { Router } from 'react-router'
44

55
/**
66
* The public API for a <Router> that uses window.location.hash.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export default from 'react-router/MemoryRouter'
1+
export { MemoryRouter as default } from 'react-router'

packages/react-router-dom/modules/NavLink.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { PropTypes } from 'react'
2-
import Route from 'react-router/Route'
2+
import { Route } from 'react-router'
33
import Link from './Link'
44

55
/**
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export default from 'react-router/Prompt'
1+
export { Prompt as default } from 'react-router'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export default from 'react-router/Redirect'
1+
export { Redirect as default } from 'react-router'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export default from 'react-router/Route'
1+
export { Route as default } from 'react-router'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export default from 'react-router/Router'
1+
export { Router as default } from 'react-router'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export default from 'react-router/StaticRouter'
1+
export { StaticRouter as default } from 'react-router'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export default from 'react-router/Switch'
1+
export { Switch as default } from 'react-router'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export default from 'react-router/matchPath'
1+
export { matchPath as default } from 'react-router'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export default from 'react-router/withRouter'
1+
export { withRouter as default } from 'react-router'

packages/react-router-dom/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,14 @@
2424
"matchPath.js",
2525
"withRouter.js",
2626
"README.md",
27+
"es",
2728
"umd"
2829
],
2930
"main": "index.js",
31+
"module": "es/index.js",
3032
"scripts": {
31-
"build-lib": "babel ./modules -d . --ignore __tests__",
33+
"build-es": "BABEL_ENV=es babel modules -d es --ignore __tests__",
34+
"build-lib": "BABEL_ENV=cjs babel modules -d . --ignore __tests__",
3235
"build-umd": "webpack modules/index.js umd/react-router-dom.js",
3336
"build-min": "webpack -p modules/index.js umd/react-router-dom.min.js",
3437
"build": "node ./scripts/build.js",

packages/react-router-dom/scripts/build.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const webpackEnv = Object.assign({}, process.env, {
1515
NODE_ENV: 'production'
1616
})
1717

18+
exec('npm run build-es')
1819
exec('npm run build-lib')
1920
exec('npm run build-umd', webpackEnv)
2021
exec('npm run build-min', webpackEnv)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const buildPreset = require('babel-preset-es2015').buildPreset
2+
3+
const BABEL_ENV = process.env.BABEL_ENV
4+
5+
module.exports = {
6+
presets: [
7+
[ buildPreset, {
8+
loose: true,
9+
modules: BABEL_ENV === 'es' ? false : 'commonjs'
10+
} ]
11+
]
12+
}

packages/react-router/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
es
12
umd
23
node_modules
34
/*.js

packages/react-router/modules/.babelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"presets": [
3-
[ "es2015", { "loose": true } ],
3+
"../tools/es2015Preset",
44
"stage-1",
55
"react"
66
],

packages/react-router/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@
2020
"matchPath.js",
2121
"withRouter.js",
2222
"README.md",
23+
"es",
2324
"umd"
2425
],
2526
"main": "index.js",
27+
"module": "es/index.js",
2628
"scripts": {
27-
"build-lib": "babel ./modules -d . --ignore __tests__",
29+
"build-es": "BABEL_ENV=es babel modules -d es --ignore __tests__",
30+
"build-lib": "BABEL_ENV=cjs babel modules -d . --ignore __tests__",
2831
"build-umd": "webpack modules/index.js umd/react-router.js",
2932
"build-min": "webpack -p modules/index.js umd/react-router.min.js",
3033
"build": "node ./scripts/build.js",

packages/react-router/scripts/build.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const webpackEnv = Object.assign({}, process.env, {
1515
NODE_ENV: 'production'
1616
})
1717

18+
exec('npm run build-es')
1819
exec('npm run build-lib')
1920
exec('npm run build-umd', webpackEnv)
2021
exec('npm run build-min', webpackEnv)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const buildPreset = require('babel-preset-es2015').buildPreset
2+
3+
const BABEL_ENV = process.env.BABEL_ENV
4+
5+
module.exports = {
6+
presets: [
7+
[ buildPreset, {
8+
loose: true,
9+
modules: BABEL_ENV === 'es' ? false : 'commonjs'
10+
} ]
11+
]
12+
}

0 commit comments

Comments
 (0)