ECMAScript 2015 getExports
Retrieve a list of export names from an ECMAScript 2015 module file in Node.js, without evaluating the module.
Usage
Given the following module in 'my/module.js':
{ return "Hello!";} const YES_CONSTANT = 'YES';const NO_CONSTANT = 'NO'; ;42;
This code with retrieve the names of all exports:
; ;
Note: This version will only work for Harmony ECMAScript modules. CommonJS modules will yield an empty list.
API
: Promise<(string|object)[]>
Returns a standard Promise containing a list of strings (may contain object placeholders iff the recursive
option is false.
Options
- base : The relative directory path for resolving the module file. When relative to the caller module's directory, simply assign this to
__dirpath
. - recursive : [default is true] whether to resolve
import * from
statements recursively. If false, a placeholder object{allFrom: string, toResolve = true}
is added to the list and no further resolution is made.
License
MIT