So in ES2015 you can:
export const FOO = 0;
export const BAR = 1;
import * as AExports from 'ModuleA';
console.log(AExports.FOO);
What is the official way to list ModuleA exports at runtime?
import * as AExports from 'ModuleA';
Object.keys(AExports);
[...AExports];
Object.getOwnPropertyNames(AExports);
As far as I can tell, spec describes this as ImportedBinding, but I cannot extract any of this.
NameSpaceImport : * as ImportedBinding
Let localName be the StringValue of ImportedBinding.
Let entry be the Record {[[ModuleRequest]]: module, [[ImportName]]: "*", [[LocalName]]: localName }.
Return a new List containing entry.
source
share