module: fix cyclical dynamic import
ensures that instantiation result is only used during initial loading PR-URL: https://github.com/nodejs/node/pull/18965 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Jan Krems <jan.krems@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
parent
ae3137049f
commit
023f49c5a9
@ -50,10 +50,11 @@ class ModuleJob {
|
||||
}
|
||||
|
||||
async instantiate() {
|
||||
if (this.instantiated) {
|
||||
return this.instantiated;
|
||||
if (!this.instantiated) {
|
||||
return this.instantiated = this._instantiate();
|
||||
}
|
||||
return this.instantiated = this._instantiate();
|
||||
await this.instantiated;
|
||||
return this.module;
|
||||
}
|
||||
|
||||
// This method instantiates the module associated with this job and its
|
||||
|
3
test/es-module/test-esm-cyclic-dynamic-import.mjs
Normal file
3
test/es-module/test-esm-cyclic-dynamic-import.mjs
Normal file
@ -0,0 +1,3 @@
|
||||
// Flags: --experimental-modules
|
||||
import '../common';
|
||||
import('./test-esm-cyclic-dynamic-import');
|
Loading…
x
Reference in New Issue
Block a user