Skip to content

Commit

Permalink
Make it possible to specify loader in config
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Jul 13, 2014
1 parent 255de2d commit 5304f1c
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 7 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ var Button = require('react-hot!./button');

When a component is imported that way, changes to its code should be applied **without unmounting it or losing its state**.

You can also specify loader in config before `jsx-loader`:

```javascript
module: {
loaders: [
{ test: /\.jsx$/, loaders: ['react-hot', 'jsx-loader'] }
]
}
```

This will enable hot reload for all JSX files.

# License

MIT (http://www.opensource.org/licenses/mit-license.php)
2 changes: 1 addition & 1 deletion example/a.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @jsx React.DOM */

var React = require('react'),
B = require('react-hot!./b');
B = require('./b');

var A = React.createClass({
getInitialState: function () {
Expand Down
2 changes: 1 addition & 1 deletion example/app.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @jsx React.DOM */

var React = require('react'),
A = require('react-hot!./a');
A = require('./a');

React.renderComponent(<A />, document.body);
2 changes: 1 addition & 1 deletion example/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = {
},
module: {
loaders: [
{ test: /\.jsx$/, loader: 'jsx-loader' }
{ test: /\.jsx$/, loaders: ['react-hot', 'jsx-loader'] }
]
}
};
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ module.exports.pitch = function (remainingRequest) {
' return require("react").createClass(spec);',
'};',
'if (module.hot) {',
' module.hot.accept(' + JSON.stringify('replaceCreateClass!' + moduleRequest) + ', function() {',
' module.exports = require(' + JSON.stringify('replaceCreateClass!' + moduleRequest) + ')(createHotClass);',
' module.hot.accept(' + JSON.stringify('!!replaceCreateClass!' + moduleRequest) + ', function() {',
' module.exports = require(' + JSON.stringify('!!replaceCreateClass!' + moduleRequest) + ')(createHotClass);',
' HotUpdateMixin.acceptUpdate(module.exports);',
' });',
'}',
'module.exports = require(' + JSON.stringify('replaceCreateClass!' + moduleRequest) + ')(createHotClass);'
'module.exports = require(' + JSON.stringify('!!replaceCreateClass!' + moduleRequest) + ')(createHotClass);'
].join('\n');
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-hot-loader",
"version": "0.1.2",
"version": "0.1.3",
"description": "Webpack loader that enables live-editing React components without unmounting or losing their state",
"main": "index.js",
"directories": {
Expand Down

0 comments on commit 5304f1c

Please sign in to comment.