-
Notifications
You must be signed in to change notification settings - Fork 151
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
recast
with espree
failed on new.target
#352
Comments
Perhaps you could give a small heads up what this |
Or maybe we can have an option to customize the parser used by |
Well... I'll need to take a closer look when I get back. Possibly Lebab could switch to a different parser. I don't really remember why exactly it uses espree. There likely were some issues with other parsers. But it's been a while and sure these parsers have advanced a bit. Lebab isn't really in active development. It's not really even in active maintenance. But when I feel like it, I might fix a bug or two. Though switching a parser is probably a fairly involved task. |
I can understand the status of this project. Don't worry 🙏 |
Sure. I'm open for a PR. |
Still can reproduce |
So, I finally started looking closer at this issue, and I'm unable to reproduce it. Testing with this snippet: function foo() { new.target } It works just fine on my machine, and when I try it in the demo site, it also works without problems. I see you patched the problem in Recast. I suggest you send that patch to Recast repository. I'm sure Recast also wants to support the Espree parser (although it doesn't explicitly list a configuration for it in its But I guess the important bit is making this bug first reproducible. Currently for me it's not. |
Run this in Node.js. Not sure why web is fine. const { transform } = require('lebab')
const code = `function foo() { new.target }`;
transform(
code, // code to transform
['let'] // transforms to apply
); |
var espree = require('espree')
var recast = require('recast')
const code = `
function foo() { new.target }
`
const ESPREE_OPTS = {
ecmaVersion: 2022,
ecmaFeatures: {jsx: true},
comment: true,
tokens: true,
range: true,
loc: true,
};
var parser = {
parse: function parse(js, opts) {
return espree.parse(js, ESPREE_OPTS);
}
};
const ast = recast.parse(code, { parser })
const result = recast.print(ast, {
lineTerminator: '\n',
objectCurlySpacing: false,
}).code;
console.log(result); |
Tried. Works without issues. |
This other example also works without issue for me. |
Also running in codesandbox.io |
Hmm. What OS did you use? Mine: |
It works fine on my Mac. WTF. |
Yeah, I'm using Mac. Node 18. |
Perhaps there's something off with your windows environment. Maybe you can ask somebody to try it on Windows. I currently don't have a Windows at hand. |
I'd suspect it's a difference in Node environment, not a difference in OS. |
I know this might look like I'm reporting in the wrong place. Let me explain.
espree
can parse the code without errorrecast
withespree
will have this errorrecast
with default parser (esprima
) will not have this errorrecast
does not officially supportespree
as parser, that why I report it hereI don't know which project should be responsible for this.
I have tried various
espree
options to make it work. But failed.Input
Output
The wrong node is the
new.target
(MetaProperty)The text was updated successfully, but these errors were encountered: