escodegen icon indicating copy to clipboard operation
escodegen copied to clipboard

Allow specifying the original name of nodes

Open iBelieve opened this issue 4 years ago • 3 comments

See #118, https://github.com/estools/esmangle/issues/85

iBelieve avatar May 03 '20 12:05 iBelieve

We can't do this. estree AST nodes are today allowed to have fields other than those specified by estree. Some of those nodes may have an originalName property that was not meant to cause codegen to behave like this. Additionally, how do you know that the code generator isn't being used to output the minified names?

I think you should start by explaining the problem you have so we can discuss solutions to it.

michaelficarra avatar May 04 '20 22:05 michaelficarra

@michaelficarra The linked issue already explains the problem and essentially proposes this solution: https://github.com/estools/esmangle/issues/85. Without this fix, source maps don't include the original identifiers, and incorrectly include the minified names. This means that for example stack traces will refer to minified function names. With this fix, you can see the original, un-minified function names in the stack trace.

iBelieve avatar May 05 '20 02:05 iBelieve

@iBelieve Okay, I think I was misreading this PR. It doesn't change the actual source text generation, just the names used in the source map, is that correct? Can you add tests that Identifier nodes that have both a name and an originalName still codegen using the name?

michaelficarra avatar May 05 '20 17:05 michaelficarra