Skip to content
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

Generators using escodegen-wallaby seem to be failing #27

Open
ebuzzz opened this issue May 26, 2016 · 7 comments
Open

Generators using escodegen-wallaby seem to be failing #27

ebuzzz opened this issue May 26, 2016 · 7 comments

Comments

@ebuzzz
Copy link

ebuzzz commented May 26, 2016

I'm experiencing a strange problem. My action and reducer generators are no longer working. They just return after a few seconds. When I disable the attachToConstants and attachToApp calls, the template file is written correctly. But the system fails in the escodegenJsx.generate call:

const write = function(path, tree) {
  tree = escodegenJsx.attachComments(tree, tree.comments, tree.tokens);
  const options = { comment: true, format: { indent: { style: '  ' } } };
  const code = escodegenJsx.generate(tree, options) + '\n';
  fs.writeFileSync(path, code, 'utf8');
};

The thing I noticed, is that my tree is containing ExportDeclaration elements (and the generator also adds one). But my escodegen does not support this type (it does support ExportDefaultDeclaration and more). Is this bug introduced in some newer version of the generator and libraries?

@ebuzzz
Copy link
Author

ebuzzz commented May 26, 2016

I've made a pull request #28 that fixed the problem by downgrading escodegen-wallaby to 1.6.6 (preventing the use of 1.6.7)

@stylesuxx stylesuxx added the bug label May 26, 2016
@stylesuxx
Copy link
Owner

stylesuxx commented May 26, 2016

Good catch. Thank you.

I am not sure if it would not be better (and cleaner) to refactor the code so it is compatible with the newer version.

I will look into this - give me a couple of days to decide.

@ebuzzz
Copy link
Author

ebuzzz commented May 27, 2016

The main problem is with the esprima-fb library. You can change the new elements that you append, but when loading the existing files, esprima-fb converts the nodes to ExportDeclaration elements. And because esprima-fb is not maintained, it could prove difficult to change that behavior...

@stylesuxx
Copy link
Owner

Oh, great you did some research. In this case freezing the version as you suggested is the only way to go. Quite a bummer, I have to admit :-/

@stylesuxx
Copy link
Owner

Merged your PR - thank you.

Published new version to NPM.

I'll leave this open for now since I do not like the fact to rely on a deprecated module and forever be locked on a specific version of a dependent module that is still being developed.

@stylesuxx stylesuxx added enhancement and removed bug labels May 28, 2016
@stylesuxx
Copy link
Owner

Seems Facebook has deprecated it in favor of Acorn and it's JSX plugin

@stylesuxx
Copy link
Owner

Just to update this issues. I have toyed around with acorn but things do not seem to be easy to adapt. I tried to add nodes the same way as used to from esprima-fb Unfortunately they do not seem to be inserted properly into the AST, generating source from the AST does not produce the source expected after inserting a node.

So I will leave the version pinned for now. I marked this as help wanted so feel free to submit a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants