mirror of
https://github.com/nodejs/node.git
synced 2025-05-07 19:56:48 +00:00

- Removes redundant `instantiate` method - Refactors `link` to match the spec linking steps more accurately - Removes URL validation from SourceTextModule specifiers - DRYs some dynamic import logic Closes: https://github.com/nodejs/node/issues/29030 Co-Authored-By: Michaël Zasso <targos@protonmail.com> PR-URL: https://github.com/nodejs/node/pull/29776 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
30 lines
867 B
JavaScript
30 lines
867 B
JavaScript
'use strict';
|
|
|
|
// Flags: --expose-internals
|
|
|
|
require('../common');
|
|
const assert = require('assert');
|
|
|
|
const { internalBinding } = require('internal/test/binding');
|
|
const { ModuleWrap } = internalBinding('module_wrap');
|
|
const { getPromiseDetails, isPromise } = internalBinding('util');
|
|
const setTimeoutAsync = require('util').promisify(setTimeout);
|
|
|
|
const foo = new ModuleWrap('export * from "bar"; 6;', 'foo');
|
|
const bar = new ModuleWrap('export const five = 5', 'bar');
|
|
|
|
(async () => {
|
|
const promises = foo.link(() => setTimeoutAsync(1000).then(() => bar));
|
|
assert.strictEqual(promises.length, 1);
|
|
assert(isPromise(promises[0]));
|
|
|
|
await Promise.all(promises);
|
|
|
|
assert.strictEqual(getPromiseDetails(promises[0])[1], bar);
|
|
|
|
foo.instantiate();
|
|
|
|
assert.strictEqual(await foo.evaluate(-1, false), 6);
|
|
assert.strictEqual(foo.getNamespace().five, 5);
|
|
})();
|