Refine SystemJS export rendering#4199
Conversation
Thank you for your contribution! ❤️You can try out this pull request locally by installing Rollup via npm install rollup/rollup#improve-systemjs-renderingor load it into the REPL: |
1086780 to
d0aa307
Compare
Codecov Report
@@ Coverage Diff @@
## master #4199 +/- ##
==========================================
+ Coverage 98.34% 98.37% +0.02%
==========================================
Files 202 202
Lines 7244 7254 +10
Branches 2123 2127 +4
==========================================
+ Hits 7124 7136 +12
Misses 58 58
+ Partials 62 60 -2
Continue to review full report at Codecov.
|
d0aa307 to
1d97348
Compare
1d97348 to
52ce573
Compare
| var i, j; exports({ i: i, j: j }); | ||
|
|
||
| var k, l; | ||
| var k, l; exports({ k: k, l: l }); |
There was a problem hiding this comment.
As much as possible it is usually a good idea to bulk together calls to the exports({}) function. This is because when there are export * or reexports in play, there is a cascade of function calls to propagate the binding updates, so fewer cascades are better for performance as this can degrade on very exported graphs otherwise.
There was a problem hiding this comment.
Undefined bindings are an exception, but this reduces quite a bit complexity. On the other hand, there is now much more grouping for declarations that contain more than one export, see below lines 22 and 24.
guybedford
left a comment
There was a problem hiding this comment.
Only did a brief review, but looks good to me.
This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
Description
In SystemJS, we manually need to update export bindings whenever the underlying variable changes. This PR refines and unifies the code created by Rollup, often replacing IIFEs with more efficient comma expressions.
It also fixes an issue where using a postfix unary update operator applied to a variable with more than one export name would return the updated value instead of the original value: Old REPL, New REPL.
This will also make the code easier to maintain and help when generating ES2015+ output.
Here is an overview of the most important changes: