Skip to content

Commit 881ae75

Browse files
committed
module: fix cyclical dynamic import
ensures that instantiation result is only used during initial loading
1 parent 6bdc18c commit 881ae75

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lib/internal/loader/ModuleJob.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@ class ModuleJob {
5353
}
5454

5555
async instantiate() {
56-
if (this.instantiated) {
57-
return this.instantiated;
56+
if (!this.instantiated) {
57+
return this.instantiated = this._instantiate();
5858
}
59-
return this.instantiated = this._instantiate();
59+
await this.instantiated;
60+
return this.module;
6061
}
6162

6263
// This method instantiates the module associated with this job and its
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Flags: --experimental-modules
2+
import '../common';
3+
import('./test-esm-cyclic-dynamic-import');

0 commit comments

Comments
 (0)