-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support of syntaxes? #102
Comments
If you simply pass package names into babel's list of presets then it'll try to load them from the working directory. That doesn't work for us, so we need to resolve–but not load!–the presets relative to babel-codemod itself. Fixes #102
If you simply pass package names into babel's list of presets then it'll try to load them from the working directory. That doesn't work for us, so we need to resolve–but not load!–the presets relative to babel-codemod itself. Fixes #102
🎉 This issue has been resolved in version 1.6.10 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Thanks for reporting this, @RIP21! I believe I identified the main problem, but if not please give me a little more information about your project:
Thanks! |
@eventualbuddha I will report if something will appear. Thanks :) |
@eventualbuddha I don't have .babelrc.
This is what I've got:
This is the file I try to codemod: import h from "react-hyperscript";
const StatelessComponent = props => h("h1");
const StatelessWithReturn = props => {
return h(".class", { shouldRender: lol.length > 0 });
};
function named(props) {
return h("h1");
}
class Comp extends React.Component {
render() {
return h("div.example", [
h("h1#heading", { ...getProps, ...getKnobs(), stuff: "" }),
h("h1#heading", getChildren(), [h("div")]),
h("div", [h("div", "Some content")]),
h("h1#heading", "This is hyperscript"),
h("h2", "creating React.js markup"),
h(
AnotherComponent,
{ foo: "bar", bar: () => ({}), shouldRender: thing.length > 0 },
[
h("li", [h("a", { href: "http://whatever.com" }, "One list item")]),
h("li", "Another list item")
]
)
]);
}
} This is the plugin I use https://github.com/RIP21/babel-plugin-hyperscript-to-jsx |
Okay, I think I figured it out. I need to enable all the babylon plugins in addition to using |
When transpiling required files we need to be pretty liberal about what syntax we allow, otherwise we can end up in a situation where the current node version can actually parse more natively than babylon is allowed to by `@babel/preset-env`. This should fix that. Fixes #102
When transpiling required files we need to be pretty liberal about what syntax we allow, otherwise we can end up in a situation where the current node version can actually parse more natively than babylon is allowed to by `@babel/preset-env`. This should fix that. Fixes #102
🎉 This issue has been resolved in version 1.7.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
@eventualbuddha
UPD on ^^ case: It's a babel 6 -> 7 AST difference. So it's not It throws a weird error like:
|
There's an assertion that recast is making but isn't providing a good error message for that checks that there isn't a closing element when the I traced the bug to this line: selfClosing ? bJsxCloseElem(name) : null, If you change it to this instead, it works for me: !selfClosing ? bJsxCloseElem(name) : null, and I get this output for the file you pasted above: import React from "react";
import h from "react-hyperscript";
const StatelessComponent = props => <h1 />;
const StatelessWithReturn = props => {
return <div className="class" shouldRender={lol.length > 0} />;
};
function named(props) {
return <h1 />;
}
class Comp extends React.Component {
render() {
return <div className="example"><h1 id="heading" {...getProps} {...getKnobs()} stuff="" /><h1 id="heading" {...getChildren()}><div /></h1><div><div>Some content</div></div><h1 id="heading">This is hyperscript</h1><h2>creating React.js markup</h2><AnotherComponent foo="bar" bar={() => ({})} shouldRender={thing.length > 0}><li><a href="http://whatever.com">One list item</a></li><li>Another list item</li></AnotherComponent></div>;
}
} So I'm going to leave this closed and say this is working as expected, though the error message was pretty obtuse and could be improved in recast. |
@eventualbuddha hm. Not sure if it's really expected behavior :) Maybe it's better to use |
That’s a fair point. I filed #107 to give people options. |
I have a plugin which depends on many syntaxes, and if I use
babel-cli
orbabel.transform
through the code, everything is working perfectly.When I use my plugin with codemod it's arguing, saying that I need to add react/jsx/spread etc plugins, but why should I when I just need babel to understand syntax and output code and when I have all required syntaxes already described in the plugin.
Thanks.
The text was updated successfully, but these errors were encountered: