Skip to content

Commit aac6afe

Browse files
authored
Chores: Update examples, RHL 3 & babel 6 (#59)
* chore(exampels): rm deprecated babel-plugin-react-hot * chore(examples): RHL 3 * chore(examples): update react-transform-catch-errors Babel 6 support * chore: move to babel 6 * chore(examples): add READMEs * chore(test): babel-cli for travis
1 parent 719185d commit aac6afe

File tree

28 files changed

+105
-196
lines changed

28 files changed

+105
-196
lines changed

.babelrc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
2-
"stage": 0,
3-
"loose": "all",
2+
"presets": ["es2015", "stage-0", "react"],
43
"plugins": [
54
"rewire"
65
]

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ node_js:
99
- iojs
1010
before_install:
1111
- npm i -g npm@^2.0.0
12+
- npm i -g babel-cli
1213
before_script:
1314
- npm prune
1415
after_success:

examples/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Examples
2+
At the time of this writing, we are in a bit of a limbo. `react-hot-loader` [version 3](https://github.com/gaearon/react-hot-loader/pull/240) is about to be released, but (possibly among other things) is waiting on [ErrorBoundaries in react](https://github.com/facebook/react/pull/6020), which is likely to land in the next react release.
3+
4+
Because of this, the examples have been updated to reflect the current state of deprecation and anticipation:
5+
* The [`react-hot-loader` example](react-hot-loader/) features the upcoming version 3 (currently 3.0.0-beta.2), but does not yet support error catching and rendering on updates, only on initial mount. This is the future, but it's not quite here.
6+
* The [`react-transform-catch-errors` example](react-transform-catch-errors/) shows how to catch and render errors with the deprecated `react-transform-catch-errors` plugin. This is the way of the past, but it works today.
7+
8+
## For the futurists
9+
If check out the [PR, which brings ErrorBoundaries to react](https://github.com/facebook/react/pull/6020), and build react from source, you can use the RHL 3 example __with hot reloading error capture__ today.

examples/babel-plugin-react-hot/.babelrc

Lines changed: 0 additions & 10 deletions
This file was deleted.

examples/babel-plugin-react-hot/components/App.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

examples/babel-plugin-react-hot/error-catcher.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

examples/babel-plugin-react-hot/index.html

Lines changed: 0 additions & 15 deletions
This file was deleted.

examples/babel-plugin-react-hot/index.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

examples/babel-plugin-react-hot/package.json

Lines changed: 0 additions & 22 deletions
This file was deleted.

examples/babel-plugin-react-hot/webpack.config.js

Lines changed: 0 additions & 39 deletions
This file was deleted.

examples/react-hot-loader-example/index.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

examples/react-hot-loader/.babelrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"presets": ["es2015", "stage-0", "react"],
3+
"env": {
4+
"development": {
5+
"plugins": ["react-hot-loader/babel"]
6+
}
7+
}
8+
}

examples/react-hot-loader/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# react-hot-loader example
2+
react-hot-loader 3 ([PR](https://github.com/gaearon/react-hot-loader/pull/240)) is coming soon. This examples shows how to use `redbox-react` with this upcoming version of RHL. Once [ErrorBoundaries](https://github.com/facebook/react/pull/6020) land in `react`, this approach will also work for capturing and rendering errors on updates (= when hot reloading). For now, this only works on initial mount.

examples/react-hot-loader/index.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import React from 'react'
2+
import {render} from 'react-dom'
3+
import {AppContainer} from 'react-hot-loader'
4+
import App from './components/App'
5+
import Redbox from 'redbox-react'
6+
7+
const root = document.getElementById('root')
8+
render(<AppContainer errorReporter={Redbox}><App /></AppContainer>, root)
9+
10+
if (module.hot) {
11+
module.hot.accept('./components/App', () => {
12+
const NextApp = require('./components/App').default
13+
render(
14+
<AppContainer errorReporter={Redbox}>
15+
<NextApp />
16+
</AppContainer>,
17+
root
18+
)
19+
})
20+
}

examples/react-hot-loader-example/package.json renamed to examples/react-hot-loader/package.json

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,17 @@
1919
},
2020
"homepage": "https://github.com/library-boilerplate-author/library-boilerplate",
2121
"dependencies": {
22-
"react": "^0.13.3"
22+
"react": "^15.0.0",
23+
"react-dom": "^15.1.0"
2324
},
2425
"devDependencies": {
25-
"babel-core": "^5.6.18",
26-
"babel-loader": "^5.1.4",
27-
"node-libs-browser": "^0.5.2",
28-
"react-hot-loader": "davidpfahler/react-hot-loader#error-reporter",
29-
"webpack": "^1.9.11",
30-
"webpack-dev-server": "^1.9.0",
31-
"webpack-error-notification": "^0.1.4"
26+
"babel-core": "^6.9.0",
27+
"babel-loader": "^6.2.4",
28+
"babel-preset-es2015": "^6.3.3",
29+
"babel-preset-react": "^6.5.0",
30+
"babel-preset-stage-0": "^6.3.13",
31+
"react-hot-loader": "^3.0.0-beta.2",
32+
"webpack": "^1.13.1",
33+
"webpack-dev-server": "^1.14.1"
3234
}
3335
}
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,22 @@
11
var path = require('path')
22
var webpack = require('webpack')
3-
var WebpackErrorNotificationPlugin = require('webpack-error-notification')
43

54
module.exports = {
65
devtool: 'eval',
76
entry: [
87
'webpack-dev-server/client?http://localhost:3000',
98
'webpack/hot/only-dev-server',
9+
'react-hot-loader/patch',
1010
'./index'
1111
],
1212
output: {
1313
path: path.join(__dirname, 'dist'),
1414
filename: 'bundle.js',
15-
publicPath: '/static/'
15+
publicPath: '/static/',
16+
devtoolModuleFilenameTemplate: '/[absolute-resource-path]'
1617
},
1718
plugins: [
18-
new webpack.HotModuleReplacementPlugin(),
19-
new webpack.NoErrorsPlugin(),
20-
new WebpackErrorNotificationPlugin(),
21-
new webpack.DefinePlugin({
22-
__CLIENT__: true,
23-
__SERVER__: false,
24-
__DEV__: true,
25-
__DEVTOOLS__: true // <-- Toggle redux-devtools
26-
})
19+
new webpack.HotModuleReplacementPlugin()
2720
],
2821
resolve: {
2922
alias: {
@@ -34,16 +27,13 @@ module.exports = {
3427
module: {
3528
loaders: [{
3629
test: /\.js$/,
37-
loaders: ['react-hot?errorReporter=redbox-react', 'babel'],
30+
loaders: ['babel'],
3831
exclude: /node_modules/,
3932
include: __dirname
4033
}, {
4134
test: /\.js$/,
4235
loaders: ['babel'],
4336
include: path.join(__dirname, '..', '..', 'src')
44-
}, {
45-
test: /\.css?$/,
46-
loader: 'style-loader!css-loader?sourceMap&modules&localIdentName=[path][name]---[local]---[hash:base64:5]'
4737
}]
4838
}
4939
}
Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
{
2-
"stage": 0,
2+
"presets": ["es2015", "stage-0", "react"],
33
"env": {
44
"development": {
5-
"plugins": ["react-transform"],
6-
"extra": {
7-
"react-transform": [{
8-
"target": "react-transform-hmr",
9-
"imports": ["react"],
10-
"locals": ["module"]
11-
}, {
12-
"target": "react-transform-catch-errors",
13-
"imports": [
14-
"react",
15-
"redbox-react",
16-
"./reporterOptions"
17-
]
18-
}]
19-
}
5+
"plugins": [
6+
[
7+
"react-transform", {
8+
"transforms": [{
9+
"transform": "react-transform-catch-errors",
10+
"imports": [
11+
"react",
12+
"redbox-react",
13+
"../reporterOptions.js"
14+
]
15+
}]
16+
}
17+
]
18+
]
2019
}
2120
}
2221
}

examples/react-transform-catch-errors/App.js

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# react-transform-catch-errors example
2+
[react-transform-catch](https://github.com/gaearon/react-transform-catch-errors) errors is deprectated, but for now, this examples shows you how to use `redbox-react` with it.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react'
2+
import ReactDOM from 'react-dom'
23
import App from './components/App'
34

45
const root = document.getElementById('root')
5-
React.render(<App />, root)
6+
ReactDOM.render(<App />, root)

examples/react-transform-catch-errors/package.json

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,18 @@
88
},
99
"license": "MIT",
1010
"dependencies": {
11-
"react": "^0.13.3"
11+
"react": "^0.14.0 || ^15.0.0",
12+
"react-dom": "^15.1.0"
1213
},
1314
"devDependencies": {
14-
"babel-core": "^5.4.7",
15-
"babel-eslint": "^3.1.9",
16-
"babel-loader": "^5.1.2",
17-
"babel-plugin-react-transform": "^1.0.1",
18-
"eslint": "^1.3.1",
19-
"eslint-plugin-react": "^2.3.0",
15+
"babel-cli": "^6.3.17",
16+
"babel-core": "^6.3.21",
17+
"babel-loader": "^6.0.0",
18+
"babel-plugin-react-transform": "^2.0.2",
19+
"babel-preset-es2015": "^6.3.3",
20+
"babel-preset-stage-0": "^6.3.13",
2021
"express": "^4.13.3",
21-
"react-transform-catch-errors": "^1.0.0",
22-
"react-transform-hmr": "^1.0.0",
23-
"redbox-react": "^1.0.1",
22+
"react-transform-catch-errors": "^1.0.2",
2423
"rimraf": "^2.4.3",
2524
"webpack": "^1.9.6",
2625
"webpack-dev-middleware": "^1.2.0",

examples/react-transform-catch-errors/webpack.config.dev.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
var path = require('path');
2-
var webpack = require('webpack');
1+
var path = require('path')
2+
var webpack = require('webpack')
33

44
module.exports = {
5-
devtool: 'eval',
65
entry: [
76
'webpack-hot-middleware/client',
87
'./index'
98
],
109
output: {
1110
path: path.join(__dirname, 'dist'),
1211
filename: 'bundle.js',
13-
publicPath: '/static/'
12+
publicPath: '/static/',
13+
devtoolModuleFilenameTemplate: '/[absolute-resource-path]'
1414
},
15+
devtool: 'eval',
1516
plugins: [
1617
new webpack.HotModuleReplacementPlugin(),
1718
new webpack.NoErrorsPlugin()
@@ -31,7 +32,8 @@ module.exports = {
3132
}, {
3233
test: /\.js$/,
3334
loaders: ['babel'],
35+
exclude: /node_modules/,
3436
include: path.join(__dirname, '..', '..', 'src')
3537
}]
3638
}
37-
};
39+
}

0 commit comments

Comments
 (0)