You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
letMyClass=(()=>{varMyClass=class{}returnMyClass;})();console.log(MyClass.name);// prints "MyClass"
When transformed, this code becomes - note that the behavior has changed:
letMyClass=/* @__PURE__ */(()=>{varMyClass2=class{};returnMyClass2;})();console.log(MyClass.name);// prints "MyClass2"
I'm aware that the keepNames option exists, but I would argue that it should not be necessary in this case. var MyClass only exists in the function scope and there is no other identifier with the same name in there.
As a result, the var should not be renamed and esbuild should instead generate the following code:
letMyClass=/* @__PURE__ */(()=>{varMyClass=class{};returnMyClass;})();console.log(MyClass.name);// prints "MyClass"
The text was updated successfully, but these errors were encountered:
I'm using esbuild to transpile ESM generated by TypeScript into CJS. The actual code is a bit more complex, but I was able to reduce it to a minimal case:
https://esbuild.github.io/try/#dAAwLjI0LjAAAGxldCBNeUNsYXNzID0gKCgpID0+IHsKICAgIHZhciBNeUNsYXNzID0gY2xhc3Mge30KICAgIHJldHVybiBNeUNsYXNzOwp9KSgpOwoKY29uc29sZS5sb2coTXlDbGFzcy5uYW1lKTs
When transformed, this code becomes - note that the behavior has changed:
I'm aware that the
keepNames
option exists, but I would argue that it should not be necessary in this case.var MyClass
only exists in the function scope and there is no other identifier with the same name in there.As a result, the
var
should not be renamed and esbuild should instead generate the following code:The text was updated successfully, but these errors were encountered: