mirror of
https://github.com/nodejs/node.git
synced 2025-05-10 17:57:53 +00:00

At the last TC39 meeting, a new type of Module Records backed by JavaScript source called Dynamic Module Records was discussed, and it is now at Stage 1. Regardless of whether that proposal makes it all the way into the spec, SourceTextModule is indeed a more descriptive and accurate name for what this class represents. PR-URL: https://github.com/nodejs/node/pull/22007 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Jan Krems <jan.krems@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Yuta Hiroto <hello@hiroppy.me> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: John-David Dalton <john.david.dalton@gmail.com> Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
21 lines
525 B
JavaScript
21 lines
525 B
JavaScript
'use strict';
|
|
|
|
// Flags: --experimental-vm-modules
|
|
|
|
require('../common');
|
|
const assert = require('assert');
|
|
|
|
const { SourceTextModule } = require('vm');
|
|
const { inspect } = require('util');
|
|
|
|
(async () => {
|
|
const m = new SourceTextModule('export const a = 1; export var b = 2');
|
|
await m.link(() => 0);
|
|
m.instantiate();
|
|
assert.strictEqual(
|
|
inspect(m.namespace),
|
|
'[Module] { a: <uninitialized>, b: undefined }');
|
|
await m.evaluate();
|
|
assert.strictEqual(inspect(m.namespace), '[Module] { a: 1, b: 2 }');
|
|
})();
|