Skip to content

Commit

Permalink
chore(*): setup babel-preset-react-hmre - enhancement of previous commit
Browse files Browse the repository at this point in the history
As exposed in https://github.com/danmartinez101/babel-preset-react-hmre this preset ships the following transformers:
* babel-plugin-react-transform (the babel plugin that makes it all possible): https://github.com/gaearon/babel-plugin-react-transform
* react-transform-hmr (transformer in charge of hot module reloading): https://github.com/gaearon/react-transform-hmr
* react-transform-catch-errors (will show runtime errors on screen): https://github.com/gaearon/react-transform-catch-errors
* redbox-react (the component used by catch-errors): https://github.com/KeywordBrain/redbox-react

This preset abstracts all those plugins in one package. All you have to do to have your React project ready for hor reload on babel v6 is now:

npm install babel-preset-react-hmre --save-dev

And set your .babelrc to (the preset part being important):

{
  "presets": ["react", "es2015"],
  "env": {
    "development": {
      "presets": ["react-hmre"]
    }
  }
}

If you prefer to know exactly what you're using (not a preset that abstracts a bunch of plugins, take a look at #90c6088 )
  • Loading branch information
topheman committed Mar 28, 2016
1 parent 90c6088 commit aa19dd9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
12 changes: 1 addition & 11 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,7 @@
"env": {
// only enable it when process.env.NODE_ENV is 'development' or undefined
"development": {
"plugins": [["react-transform", {
"transforms": [{
"transform": "react-transform-hmr",
// if you use React Native, pass "react-native" instead:
"imports": ["react"],
// this is important for Webpack HMR:
"locals": ["module"]
}]
// note: you can put more transforms into array
// this is just one of them!
}]]
"presets": ["react-hmre"]
}
}
}
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@
"babel-eslint": "^5.0.0",
"babel-loader": "^6.2.4",
"babel-plugin-add-module-exports": "^0.1.2",
"babel-plugin-react-transform": "^2.0.2",
"babel-plugin-transform-class-properties": "^6.6.0",
"babel-plugin-transform-es2015-destructuring": "^6.6.5",
"babel-plugin-transform-object-rest-spread": "^6.6.5",
"babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0",
"babel-preset-react-hmre": "^1.1.1",
"css-loader": "^0.23.1",
"del": "^2.0.2",
"eslint": "^1.10.3",
Expand All @@ -87,7 +87,6 @@
"pre-commit": "^1.1.2",
"protractor": "^3.0.0",
"react-addons-test-utils": "^0.14.7",
"react-transform-hmr": "^1.0.4",
"sass-loader": "^3.1.2",
"serve": "^1.4.0",
"style-loader": "^0.13.0",
Expand Down

0 comments on commit aa19dd9

Please sign in to comment.