forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This fixes an annoying bug where the entry module would link before its dependencies were linked. This is fixed by forcing modules to wait for all dependency linker promises to resolve. Fixes: nodejs#37426 Signed-off-by: snek <[email protected]>
- Loading branch information
Showing
3 changed files
with
72 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use strict'; | ||
|
||
const { SourceTextModule, SyntheticModule } = require('vm'); | ||
|
||
const tm = new SourceTextModule('import "a"'); | ||
|
||
tm | ||
.link(async () => { | ||
const tm2 = new SourceTextModule('import "b"'); | ||
tm2.link(async () => { | ||
const sm = new SyntheticModule([], () => {}); | ||
await sm.link(() => {}); | ||
await sm.evaluate(); | ||
return sm; | ||
}).then(() => tm2.evaluate()); | ||
return tm2; | ||
}) | ||
.then(() => tm.evaluate()) | ||
.then(() => { | ||
console.log('dun'); | ||
}) | ||
.catch((e) => { | ||
console.error(e); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Flags: --experimental-vm-modules | ||
|
||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const { SourceTextModule, SyntheticModule } = require('vm'); | ||
|
||
const tm = new SourceTextModule('import "a"'); | ||
|
||
tm | ||
.link(async () => { | ||
const tm2 = new SourceTextModule('import "b"'); | ||
tm2.link(async () => { | ||
const sm = new SyntheticModule([], () => {}); | ||
await sm.link(() => {}); | ||
await sm.evaluate(); | ||
return sm; | ||
}).then(() => tm2.evaluate()); | ||
return tm2; | ||
}) | ||
.then(() => tm.evaluate()) | ||
.then(common.mustCall()) | ||
.catch(common.mustNotCall()); |