react-hot-loader
Advanced tools
Comparing version 0.1.0 to 0.1.2
/** @jsx React.DOM */ | ||
var React = require('react'), | ||
B = require('react-hot?B!./b'); | ||
B = require('react-hot!./b'); | ||
@@ -16,3 +16,3 @@ var A = React.createClass({ | ||
<div> | ||
<p>Open this editor, edit and save <code>example/a.jsx</code>.</p> | ||
<p>Open an editor, edit and save <code>example/a.jsx</code>.</p> | ||
<p><b>The number should not change.</b></p> | ||
@@ -19,0 +19,0 @@ |
/** @jsx React.DOM */ | ||
var React = require('react'), | ||
A = require('react-hot?A!./a'); | ||
A = require('react-hot!./a'); | ||
React.renderComponent(<A />, document.body); |
39
index.js
@@ -1,2 +0,2 @@ | ||
module.exports = function() {}; | ||
module.exports = function () {}; | ||
module.exports.pitch = function (remainingRequest) { | ||
@@ -9,34 +9,15 @@ this.cacheable && this.cacheable(); | ||
'var HotUpdateMixin = require(' + JSON.stringify(require.resolve('./makeHotUpdateMixin')) + ')();', | ||
'var React = require("react");', | ||
'function runWithMonkeyPatchedReact(f) {', | ||
' var realCreateClass = React.createClass;', | ||
' var injected = 0;', | ||
' React.createClass = function createHotUpdateClass(spec) {', | ||
' if (spec.displayName === ' + JSON.stringify(displayName) + ') {', | ||
' if (!spec.mixins) spec.mixins = [];', | ||
' spec.mixins.push(HotUpdateMixin.Mixin);', | ||
' injected++;', | ||
' }', | ||
' return realCreateClass(spec);', | ||
' };', | ||
' f();', | ||
' if (injected === 0) {', | ||
' console.warn(\'Could not find component with displayName: ' + JSON.stringify(displayName) + '\');', | ||
' } else if (injected > 1) {', | ||
' console.warn(\'Found more than one component with displayName: ' + JSON.stringify(displayName) + '\');', | ||
' }', | ||
' React.createClass = realCreateClass;', | ||
'}', | ||
'runWithMonkeyPatchedReact(function () {', | ||
' module.exports = require(' + JSON.stringify(moduleRequest) + ');', | ||
'});', | ||
'function createHotClass(spec) {', | ||
' if (!spec.mixins) spec.mixins = [];', | ||
' spec.mixins.push(HotUpdateMixin.Mixin);', | ||
' return require("react").createClass(spec);', | ||
'};', | ||
'if (module.hot) {', | ||
' module.hot.accept(' + JSON.stringify(moduleRequest) + ', function() {', | ||
' runWithMonkeyPatchedReact(function () {', | ||
' module.exports = require(' + JSON.stringify(moduleRequest) + ');', | ||
' });', | ||
' 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);' | ||
].join('\n'); | ||
}; |
{ | ||
"name": "react-hot-loader", | ||
"version": "0.1.0", | ||
"version": "0.1.2", | ||
"description": "Webpack loader that enables live-editing React components without unmounting or losing their state", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -20,6 +20,2 @@ # react-hot-loader | ||
### Limitations | ||
* You have to include component's displayName in `require` call | ||
### Implementation Notes | ||
@@ -30,2 +26,5 @@ | ||
>The problem is that references to component descriptors could be stored in any number of places. What we could do is wrap all components in "proxy" components which look up the "real" component in some mapping | ||
## Installation | ||
@@ -40,4 +39,3 @@ | ||
```javascript | ||
// Currently you have to pass displayName to require call: | ||
var Button = require('react-hot?Button!./button'); | ||
var Button = require('react-hot!./button'); | ||
``` | ||
@@ -44,0 +42,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10
6448
142
45