Comments (12)
@guybedford Thanks for your time on this stuff, as always. :)
Might the best solution actually be to revisit babel/babel#2148? Or I'm I wrong in thinking that the algorithm you described there would solve this issue and all others like it? Regardless, it seems to me like there must be some way to determine whether a module was originally ES6, and if so and if it's imported into a CJS module (or another transpiled ES6 module with default
specified of course), then use the default
rather than the entire ES6 module object.
from babel-plugin-react-transform.
@timbur sure no problem, it's a good use case to cover.
I think the issue here is actually just that the file.addImport
API call to Babel needs to access the default
export to be like import x from 'x'
instead of import * as x from 'x'
for correct interop, which should then handle the use case completely fine. This may or may not be a Babel issue underneath, I'm not completely sure yet.
from babel-plugin-react-transform.
When you come to a conclusion let me know and I'll happily add a workaround you think is right.
from babel-plugin-react-transform.
I think the issue here is actually just that the file.addImport API call to Babel needs to access the default export to be like import x from 'x' instead of import * as x from 'x' for correct interop
Ohh I see. That makes the most sense and could be exactly the problem.
from babel-plugin-react-transform.
Sure thanks, I've posted babel/babel#2496.
from babel-plugin-react-transform.
Just to update here - apparently addImport
isn't a public API. The issue here is definitely with that function not handling the interop scenarios.
from babel-plugin-react-transform.
I think that actually if I use file.addImport
directly (effectively reverting d4c90c7) it will work as you described. Can you confirm this is the change you need?
from babel-plugin-react-transform.
@gaearon No, it still imports the entire module object rather than the default
.
Actually, hold on...
from babel-plugin-react-transform.
I thought maybe I could use a JSPM override to make it work but no, d4c90c7 definitely breaks it by importing the entire module object rather than the module's default
export.
from babel-plugin-react-transform.
So will reverting it help? I can do that.
from babel-plugin-react-transform.
Yeah reverting it to match my PR fixed the problem for me.
from babel-plugin-react-transform.
I think this is probably fixed because we no longer use absolute
in the source.
Please reopen if still an issue.
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.