estools / escodegen

ECMAScript code generator
BSD 2-Clause "Simplified" License
2.64k stars 334 forks source link

Add support Class field declarations #438

Open DrawAChicken opened 3 years ago

DrawAChicken commented 3 years ago

This is required because Acorn uses acorn-class-fields.

DrawAChicken commented 3 years ago

What is wrong with CL

ajvincent commented 3 years ago

Looking at the build logs versus https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes#browser_compatibility, the bug is obvious. Classes field support started in Node 12, but the .travis.yml file mandates testing against Node 6, 8, and 10.

palant commented 2 years ago

Looking at the build logs versus https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes#browser_compatibility, the bug is obvious. Classes field support started in Node 12, but the .travis.yml file mandates testing against Node 6, 8, and 10.

No, the Node version is irrelevant here. The parser used is acorn, and the issue is that test/compare-acorn-es2019/ directory is being processed without the acorn-class-fields plugin. Here:

https://github.com/estools/escodegen/blob/7a48a218cff99cd38e38e54ac8f310196314702e/test/compare-acorn-es2019.js#L39-L45

And here:

https://github.com/estools/escodegen/blob/7a48a218cff99cd38e38e54ac8f310196314702e/test/compare-acorn-es2019.js#L58-L64

kevincox commented 3 months ago

I added a PR that supersedes this with more tests that pass: https://github.com/estools/escodegen/pull/465