• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Flags: --experimental-vm-modules
2'use strict';
3const common = require('../common');
4const assert = require('assert');
5
6const { SourceTextModule } = require('vm');
7const { inspect } = require('util');
8
9(async () => {
10  const m = new SourceTextModule('export const a = 1; export var b = 2');
11  await m.link(() => 0);
12  assert.strictEqual(
13    inspect(m.namespace),
14    '[Module: null prototype] { a: <uninitialized>, b: undefined }'
15  );
16  await m.evaluate();
17  assert.strictEqual(
18    inspect(m.namespace),
19    '[Module: null prototype] { a: 1, b: 2 }'
20  );
21})().then(common.mustCall());
22