Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ES build to react-router and react-router-dom (#4425) #4432

Merged
merged 1 commit into from
Feb 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/react-router-dom/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
es
umd
node_modules
/*.js
Expand Down
2 changes: 1 addition & 1 deletion packages/react-router-dom/modules/.babelrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"presets": [
[ "es2015", { "loose": true } ],
"../tools/es2015Preset",
"stage-1",
"react"
],
Expand Down
2 changes: 1 addition & 1 deletion packages/react-router-dom/modules/BrowserRouter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { PropTypes } from 'react'
import createHistory from 'history/createBrowserHistory'
import Router from 'react-router/Router'
import { Router } from 'react-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
@@ -1,6 +1,6 @@
import React, { PropTypes } from 'react'
import createHistory from 'history/createHashHistory'
import Router from 'react-router/Router'
import { Router } from 'react-router'

/**
* The public API for a <Router> that uses window.location.hash.
Expand Down
2 changes: 1 addition & 1 deletion packages/react-router-dom/modules/MemoryRouter.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default from 'react-router/MemoryRouter'
export { MemoryRouter as default } from 'react-router'
2 changes: 1 addition & 1 deletion packages/react-router-dom/modules/NavLink.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { PropTypes } from 'react'
import Route from 'react-router/Route'
import { Route } from 'react-router'
import Link from './Link'

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/react-router-dom/modules/Prompt.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default from 'react-router/Prompt'
export { Prompt as default } from 'react-router'
2 changes: 1 addition & 1 deletion packages/react-router-dom/modules/Redirect.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default from 'react-router/Redirect'
export { Redirect as default } from 'react-router'
2 changes: 1 addition & 1 deletion packages/react-router-dom/modules/Route.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default from 'react-router/Route'
export { Route as default } from 'react-router'
2 changes: 1 addition & 1 deletion packages/react-router-dom/modules/Router.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default from 'react-router/Router'
export { Router as default } from 'react-router'
2 changes: 1 addition & 1 deletion packages/react-router-dom/modules/StaticRouter.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default from 'react-router/StaticRouter'
export { StaticRouter as default } from 'react-router'
2 changes: 1 addition & 1 deletion packages/react-router-dom/modules/Switch.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default from 'react-router/Switch'
export { Switch as default } from 'react-router'
2 changes: 1 addition & 1 deletion packages/react-router-dom/modules/matchPath.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default from 'react-router/matchPath'
export { matchPath as default } from 'react-router'
2 changes: 1 addition & 1 deletion packages/react-router-dom/modules/withRouter.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default from 'react-router/withRouter'
export { withRouter as default } from 'react-router'
5 changes: 4 additions & 1 deletion packages/react-router-dom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@
"matchPath.js",
"withRouter.js",
"README.md",
"es",
"umd"
],
"main": "index.js",
"module": "es/index.js",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who is this line for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consumers of the ES build (webpack 2, rollup, etc.)

"scripts": {
"build-lib": "babel ./modules -d . --ignore __tests__",
"build-es": "BABEL_ENV=es babel modules -d es --ignore __tests__",
"build-lib": "BABEL_ENV=cjs babel modules -d . --ignore __tests__",
"build-umd": "webpack modules/index.js umd/react-router-dom.js",
"build-min": "webpack -p modules/index.js umd/react-router-dom.min.js",
"build": "node ./scripts/build.js",
Expand Down
1 change: 1 addition & 0 deletions packages/react-router-dom/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const webpackEnv = Object.assign({}, process.env, {
NODE_ENV: 'production'
})

exec('npm run build-es')
exec('npm run build-lib')
exec('npm run build-umd', webpackEnv)
exec('npm run build-min', webpackEnv)
Expand Down
12 changes: 12 additions & 0 deletions packages/react-router-dom/tools/es2015Preset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const buildPreset = require('babel-preset-es2015').buildPreset

const BABEL_ENV = process.env.BABEL_ENV

module.exports = {
presets: [
[ buildPreset, {
loose: true,
modules: BABEL_ENV === 'es' ? false : 'commonjs'
} ]
]
}
1 change: 1 addition & 0 deletions packages/react-router/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
es
umd
node_modules
/*.js
Expand Down
2 changes: 1 addition & 1 deletion packages/react-router/modules/.babelrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"presets": [
[ "es2015", { "loose": true } ],
"../tools/es2015Preset",
"stage-1",
"react"
],
Expand Down
5 changes: 4 additions & 1 deletion packages/react-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@
"matchPath.js",
"withRouter.js",
"README.md",
"es",
"umd"
],
"main": "index.js",
"module": "es/index.js",
"scripts": {
"build-lib": "babel ./modules -d . --ignore __tests__",
"build-es": "BABEL_ENV=es babel modules -d es --ignore __tests__",
"build-lib": "BABEL_ENV=cjs babel modules -d . --ignore __tests__",
"build-umd": "webpack modules/index.js umd/react-router.js",
"build-min": "webpack -p modules/index.js umd/react-router.min.js",
"build": "node ./scripts/build.js",
Expand Down
1 change: 1 addition & 0 deletions packages/react-router/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const webpackEnv = Object.assign({}, process.env, {
NODE_ENV: 'production'
})

exec('npm run build-es')
exec('npm run build-lib')
exec('npm run build-umd', webpackEnv)
exec('npm run build-min', webpackEnv)
Expand Down
12 changes: 12 additions & 0 deletions packages/react-router/tools/es2015Preset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const buildPreset = require('babel-preset-es2015').buildPreset

const BABEL_ENV = process.env.BABEL_ENV

module.exports = {
presets: [
[ buildPreset, {
loose: true,
modules: BABEL_ENV === 'es' ? false : 'commonjs'
} ]
]
}