Skip to content
This repository was archived by the owner on Aug 29, 2021. It is now read-only.
This repository was archived by the owner on Aug 29, 2021. It is now read-only.

Circular reference handling #35

@guybedford

Description

@guybedford

In a cycle like the following:

a.js

import { y } from './b.js';
await new Promise(resolve => setTimeout(resolve, 1000));
export let x = 42;

b.js

import { x } from './a.js';
await new Promise(resolve, setTimeout(resolve, 2000));
export let y = x + 1;

If I import a.js, b.js should execute first.

On the other hand, if I import b.js, a.js should execute first.

But what happens if I do both one after the other - import('a.js'), import('b.js').

  1. Should the import of a.js "own" the execution, so that the import of a.js creates promises for the execution of a.js and b.js, and the import of b.js waits on that. This way a.js is not executed until b.js has finished executing ever.
  2. Both graph executions run simultaneously: the load for a.js executes b.js, and the load for b.js executes a.js so they both execute immediately in parallel, and both resolve when both modules have finished executing.
  3. What is specified in Variant B promise refactoring #33 is a third case: the load for a.js executes b.js, and then the load for b.js resolves as soon as b.js has finished executing, but before a.js has finished executing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions