-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run imports once per VU and support import cycles (#975)
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 Additionally import cycles are now supported.This works by pre-populating what a given file(module) will export before actually evaluating 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
- Loading branch information
Showing
2 changed files
with
373 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.