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
Support for class static initialization block #4249
Conversation
Thanks! Turns out there is actually a fallback missing + of course the AST nodes. I will add some commits to your PR. |
Codecov Report
@@ Coverage Diff @@
## master #4249 +/- ##
==========================================
+ Coverage 98.37% 98.39% +0.01%
==========================================
Files 203 204 +1
Lines 7272 7283 +11
Branches 2081 2079 -2
==========================================
+ Hits 7154 7166 +12
Misses 58 58
+ Partials 60 59 -1
Continue to review full report at Codecov.
|
sure. also, feel free to close this PR if you'd rather open a new PR, as I don't want to take any credit for your work. |
6e1a108
to
4422999
Compare
This is now done from my side and includes full tree-shaking support. Please test! |
Oh, wow, awesome! Will do! |
looks good! on some initial tests I found: // original
class A {
static foo = "bar";
static someStatic() {
return "foo";
}
static {
A.foo = A.someStatic(); // not working with rollup
// this.foo = A.someStatic(); // does work with rollup
}
}
console.log(A.foo); // rollup bundle
class A {
static foo = "bar";
static someStatic() {
return "foo";
}
static {
A.someStatic();
}
}
console.log(A.foo); returns: I'll try to add a test. |
@lukastaegert I extended the static block tests with an additional class. I could not get it to fail with extending the existing |
Thanks for the test, I did some really stupid copy-and-pasting there that you discovered... Should be working correctly now, please check again! |
Thank you for your contribution! ❤️You can try out this pull request locally by installing Rollup via npm install dnalborczyk/rollup#static-block-test or load it into the REPL: |
makes sense. anything can potentially run, not just class init stuff. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔫
This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
Resolves #4250
Description
this test is currently failing.acorn
added support forclass static initialization blocks
inv8.5
(https://github.com/acornjs/acorn/blob/master/acorn/CHANGELOG.md#850-2021-09-06) which is currently being used by rollup.Update: This now implements full support for static initialization blocks including tree-shaking