LivelyKernel / LivelyKernel/lively4-core
Support Circular Dependencies
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 89
- Forks
- 25
- PR merge metrics
- No merged PRs in 30d
Description
Our babel plugin for variable recordering is currently not capable of handling circular imports properly.
Circular dependencies are solved in SystemJS via their module rewriting.
To be specific, SystemJS uses local variables to represent import bindings.
These variables are set as specified in the `setters` functions.
```JavaScript
var html, pt;
return {
setters: [function (_htmlJs) {
html = _htmlJs.default;
}, function (_graphicsJs) {
pt = _graphicsJs.pt;
}],
execute: function () {
_recorder_._05580698383529998.html = html;
_recorder_._05580698383529998.pt = pt;
class ContextMenu {
[...]
```
`setters` are generated once for each import.
If we now have a circular dependency, that variable is initially set to `undefined`.
Then, the module's `execute` function runs, producing some exports.
These exports are then used to load the circular dependent module properly.
Afterwards the exports of the circular dependent module are set again with the `setters` functions.
However, the module's `execute` does not run again.
Thus, our variable recorder field are not assigned again.
They are only assigned in the module's first run with all values of imports being `undefined`.
---
We have to rewrite the module-scoped variables in a different way.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the Babel plugin for variable reordering and compare its handling with the SystemJS module rewriting and setters described here. Done means circular imports no longer leave variable recorder fields assigned only from their initial undefined values, and the dependent module receives the later export values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- babel, javascript
- Domain
- build-system, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100