File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ // Flags: --experimental-vm-modules --expose-internals
4+ //
5+ const common = require ( '../common' ) ;
6+
7+ const assert = require ( 'assert' ) ;
8+
9+ const { types } = require ( 'util' ) ;
10+ const { SourceTextModule, wrapMap } = require ( 'internal/vm/source_text_module' ) ;
11+
12+ const { importModuleDynamicallyCallback } =
13+ require ( 'internal/process/esm_loader' ) ;
14+
15+ async function getNamespace ( ) {
16+ const m = new SourceTextModule ( '' ) ;
17+ await m . link ( ( ) => 0 ) ;
18+ m . instantiate ( ) ;
19+ await m . evaluate ( ) ;
20+ return m . namespace ;
21+ }
22+
23+ ( async ( ) => {
24+ const namespace = await getNamespace ( ) ;
25+ const m = new SourceTextModule ( 'export const A = "A";' , {
26+ importModuleDynamically : common . mustCall ( ( specifier , wrap ) => {
27+ return namespace ;
28+ } )
29+ } ) ;
30+ await m . link ( ( ) => 0 ) ;
31+ m . instantiate ( ) ;
32+ await m . evaluate ( ) ;
33+ const ns = await importModuleDynamicallyCallback ( wrapMap . get ( m ) ) ;
34+ assert . ok ( types . isModuleNamespaceObject ( ns ) ) ;
35+ } ) ( ) . then ( common . mustCall ( ) ) ;
You can’t perform that action at this time.
0 commit comments