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
Preserve rendered class names #4674
Conversation
Thank you for your contribution! ❤️You can try out this pull request locally by installing Rollup via npm install rollup/rollup#gh-4637-preserve-class-name or load it into the REPL: |
Codecov Report
@@ Coverage Diff @@
## master #4674 +/- ##
=======================================
Coverage 99.02% 99.02%
=======================================
Files 215 215
Lines 7552 7567 +15
Branches 2092 2096 +4
=======================================
+ Hits 7478 7493 +15
Misses 24 24
Partials 50 50
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
5b1ce58
to
6c4610f
Compare
6c4610f
to
d6665ee
Compare
This PR has been released as part of rollup@3.2.1. You can test it via |
Just happen to dig into here. I notice that I guess function foo() {
console.log(foo)
} is the same as var foo$1 = function foo() {
console.log(foo$1)
} |
No it is not. foo("Hello"); // logs "Hello"
function foo() {
console.log(foo)
} foo$1("Hello"); // throws because we cannot call "undefined"
var foo$1 = function foo() {
console.log(foo)
}
|
I take a look at esbuild's approach. It solves the problem in a non-intuitive(IMO) way. Anyway, thanks for the detail explaining. |
This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
Description
This PR preserves the
name
property of classes even if the class needs to be renamed due to conflicts. The solution is to rewrite bothclass foo {}
andlet foo = class {}
to e.g.let foo$1 = class foo {}
iffoo
needs to be renamed.