Comments (10)
Oh man, I have no idea how to do this that isn't going to cause a mess of other problems.
from babel-plugin-react-transform.
What kind of problems? This is exactly how React Hot Loader currently works, and it's pretty stable.
from babel-plugin-react-transform.
You'll have to explain how it works, I would check the tests in the react-hot-loader repo but you don't have any... :for_shame:
from babel-plugin-react-transform.
@thejameskyle it's just a development tool dude, not for production
from babel-plugin-react-transform.
I understand that dude, development tools need tests too.
from babel-plugin-react-transform.
Actually that's exactly why this project was started. It was easier to split RHL into several different projects than to write tests for it :-) RHL just enumerated every key in module.exports
and wrapped whatever looks like a React component. This is what I suggest to do here: wrap every export into a conservative runtime check. The wrapping function would be like
let wrappedComponents = [];
wrapExport(something) {
if (
something &&
something.prototype &&
something.prototype.isReactComponent && // only finds Component descendants but good enough
wrappedComponents.indexOf(something) === -1 // don't wrap twice
) {
wrappedComponent.push(something); // normal generated code would also need to do that
return wrapJustLikeWeWrapInGeneratedCode(something);
}
return something; // not an export we should hijack
}
Then every export
would go through this wrapper, regardless of what's in there.
Does it make sense?
This is a runtime check but it's important for many cases where we want export a React class generated by some factory in another file, and it's essential to maintain its identity.
from babel-plugin-react-transform.
+1 Would like to see this.
I am actually working on a backbone/react application and using the react-hmre
preset. This is causing react-proxy
to run on our backbone views which is an issue!
from babel-plugin-react-transform.
Interesting, can you show code that fails? In s separate issue.
from babel-plugin-react-transform.
@gaearon will do.
from babel-plugin-react-transform.
This is fixed in React Hot Loader 3.
It is built with lessons learned from both React Hot Loader and React Transform.
Iām closing the issue as unsolvable in this repo.
from babel-plugin-react-transform.
Related Issues (20)
- Local path as an argument to "transform" does not resolve the path.
- Modify the contents of the function will not be updated.
- Doesn't work with React.PureComponent HOT 1
- Template is not a function
- Deprecated with no alternative? HOT 1
- no release info or changelog for 3.0.0
- `addImport()` is deprecated in Babel 7 HOT 2
- Use without .babelrc HOT 4
- jspm with plugin-babel and react preset: "cannot read property 'transform' of undefined" HOT 1
- React transforms being run on Backbone views HOT 6
- Question: Is it a bad practice to use react-transform for production code? HOT 1
- Transform(s) to strip propTypes and displayName HOT 4
- Ember objects detected as react components HOT 5
- Appears to wrap other functions than createClass() HOT 10
- error when passing properties to createClass() HOT 4
- Future of React Transform HOT 2
- Can we have superClass Regexp matching option , for inheritance ? HOT 2
- undefined value static properties outside class HOT 3
- displayName equals 'Constructor' HOT 8
- static properties are undefined HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ššš
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from babel-plugin-react-transform.