Closed dividedmind closed 1 year ago
The official name is MethodDefinition
and not PropertyDefinition
. It would be good to verify in testing that astring
is handling it.
> require("acorn").parse("class c { m () {} }").body[0].body.body[0].type
'MethodDefinition'
https://github.com/estree/estree/blob/master/es2015.md#methoddefinition
It will be probably worthwhile to move to a babel-only format so that we do not have to rely to the less used astring
and use @babel/generator
instead. I tried doing that but it requires some non-trivial changes on the instrumentation visitors.
The official name is
MethodDefinition
and notPropertyDefinition
. It would be good to verify in testing thatastring
is handling it.> require("acorn").parse("class c { m () {} }").body[0].body.body[0].type 'MethodDefinition'
https://github.com/estree/estree/blob/master/es2015.md#methoddefinition
MethodDefinition is a different thing. This is about PropertyDefinition: https://github.com/estree/estree/blob/master/es2022.md#propertydefinition
Good work! Let's check that
astring
is handlingPropertyDefinition
first before merging.
I checked manually, it seems to work fine.
Good work! Let's check that
astring
is handlingPropertyDefinition
first before merging.
Added a test on the instrumentation side.
It will be probably worthwhile to move to a babel-only format so that we do not have to rely to the less used
astring
and use@babel/generator
instead. I tried doing that but it requires some non-trivial changes on the instrumentation visitors.
I don't think that's a good idea unless it's really necessary. It will make it more difficult if we want to switch the parser and/or generator in the future.
It will be probably worthwhile to move to a babel-only format so that we do not have to rely to the less used
astring
and use@babel/generator
instead. I tried doing that but it requires some non-trivial changes on the instrumentation visitors.I don't think that's a good idea unless it's really necessary. It will make it more difficult if we want to switch the parser and/or generator in the future.
Yeah it is really unfortunate that babel defined its own ast format. Let's keep it like this for the moment then.
MethodDefinition is a different thing. This is about PropertyDefinition: https://github.com/estree/estree/blob/master/es2022.md#propertydefinition
Arf, I should keep up with the standard :s
:tada: This PR is included in version 13.5.2 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
appmap-agent-js uses @babel/parser to parse the ECMAScript code for transformation; the output generated by that library is not 100% estree-compliant [1]. It has an
estree
plugin that reverts the deviations; however, by default not all of them are supported (apparently for @babel/parser's own backward compatibility reasons). Fortunately it has a config setting that enables them.One of these differences is that the standard node type of PropertyDefinition is called ClassProperty instead, which made the transformer unable to correctly handle ES classes.
[1] https://babeljs.io/docs/babel-parser#output
Fixes #199