-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Run imports once per VU #975
Conversation
Codecov Report
@@ Coverage Diff @@
## master #975 +/- ##
=========================================
+ Coverage 72.08% 72.1% +0.01%
=========================================
Files 131 131
Lines 9602 9607 +5
=========================================
+ Hits 6922 6927 +5
Misses 2267 2267
Partials 413 413
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #975 +/- ##
=========================================
+ Coverage 72.08% 72.1% +0.01%
=========================================
Files 131 131
Lines 9602 9608 +6
=========================================
+ Hits 6922 6928 +6
Misses 2267 2267
Partials 413 413
Continue to review full report at Codecov.
|
Previously scripts would've been ran for each time they were imported this is both slower and not how it works in most(all?) interpreters so we are changing the behavious to be more compliant. Just like in c3d3fa5 , but now we clear the cached exports when we copy the programs when making new VUs. This is needed because otherwise: 1. We share exports between VUs so there are race conditions 2. The exports from the initial compilation without context are used (when not running from archive) and this leads to not being able to call functions that need context inside imported scripts. Closes #659 and fixes #969
0d7c20f
to
b43bfa6
Compare
This works by prepopulating what a given file(module) will export before actually evaluationg the code whatsoever. This way if it requires something that requires the original module it will get the exports object as it is at that time. And because of some magic (probably in babel) we also get that the exports are bindings[1]. So even if something is not exported at the time of the import, it will still be populated later when the original file finish loading. [1]: http://2ality.com/2015/07/es6-module-exports.html#why-export-bindings Fixes #502
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.
LGTM, besides the minor copy-paste issues
btw I'm guessing that the module resolution function suffers from some of the same file path issues that |
Oh ... definitely although here it seems it was very deliberate. |
Previously scripts would've been ran for each time they were imported
this is both slower and not how it works in most(all?) interpreters
so we are changing the behavious to be more compliant.
Just like in c3d3fa5 , but now we clear
the cached exports when we copy the programs when making new VUs.
This is needed because otherwise:
(when not running from archive) and this leads to not being able to call
functions that need context inside imported scripts.
Closes #659 and fixes #969