escodegen
escodegen copied to clipboard
Unknown node type ExportDefaultDeclaration
According to #228 it should be possible to use import
statements via Esprima 2.x in the current master. Unfortunately, I still got the above error when running:
var esprima = require("esprima"); // 2.6.0
var escodegen = require("escodegen"); // master
var code = "export default 'test'";
var tree = esprima.parse(code, {
range: true,
tokens: true,
comment: true,
sourceType: "module"
});
tree = escodegen.attachComments(tree, tree.comments, tree.tokens);
escodegen.generate(tree);
seeing the same error here, the issue comes from escodegen.attachComments
which is due to fact that estraverse dependency is super outdated https://github.com/estools/escodegen/pull/266
Please update the estraverse dependency. I am currently having this issue when doing:
var program = esprima.parse(existingJs, { sourceType: 'module', range: true, tokens: true, comment: true});
...
var ast = escodegen.attachComments(program, program.comments, program.tokens);
No way to get escodegen working with comments =(.
When I manually replace estraverse in the escodegen package folder with version 4.2.0, it works fine.