-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Behavior of cyclical dynamic import() is unclear #7472
Description
Hi!
// ./a.js
import('./a.js')
In this cyclical dynamic import example, import('./a.js') executes these algorithms.
Import Calls evaluation -> HostImportModuleDynamically -> fetch an import() module script graph->fetch a single module script.
And, in the fetch a single module script algorithm, the following algorithm is executed since this is a cyclical import and './a.js' has already been fetched.
If moduleMap[(url, moduleType)] exists, asynchronously complete this algorithm with moduleMap[url / moduleType], and return. // step 6
In other words, nothing is fetched and the remaining steps of the algorithm are synchronously run within a same task because the next algorithm is skipped.
run the remaining steps as part of the fetch's process response // step 11
Finally, the fetch the descendants of and link a module script algorithm in the fetch an import() module script graph algorithm is synchronously executed and Link() is performed. The problem is that [[Status]] of a.js is still evaluating, but the Link() algorithm in the ECMAScript spec says
- Assert: module.[[Status]] is not linking or evaluating.
I think Link()(and the remaining steps) should be queued as a microtask or a task if [[Status]] of the module is evaluating so that they will be performed after the currently running task is finished.
Did I miss something?