ECMAScript 2015+/CommonJS module dependencies resolved array
npm install --save es-deps-resolved
import path from 'path';
import esDepsResolved from 'es-deps-resolved';
/* fixtures/index.js
import fileResolved from './local';
import fileUnresolved from './local-extra';
import folderResolved from './folder';
import folderUnresolved from './folder-extra';
import pkgResolved from 'pkg';
import pkgUnresolved from 'pkg-extra';
*/
esDepsResolved(path.join(__dirname, './fixtures'))
.then(result => console.log(result)); /* [
{ requested: './local', resolved: '/Users/iamstarkov/projects/es-deps-resolved/fixtures/local.js'
from: '/Users/iamstarkov/projects/es-deps-resolved/fixtures/index.js' },
{ requested: './local-extra', resolved: null,
from: '/Users/iamstarkov/projects/es-deps-resolved/fixtures/index.js' },
{ requested: './folder', resolved: '/Users/iamstarkov/projects/es-deps-resolved/fixtures/folder/index.js',
from: '/Users/iamstarkov/projects/es-deps-resolved/fixtures/index.js' },
{ requested: './folder-extra', resolved: null,
from: '/Users/iamstarkov/projects/es-deps-resolved/fixtures/index.js' },
{ requested: 'pkg', resolved: '/Users/iamstarkov/projects/es-deps-resolved/fixtures/node_modules/pkg/index.js',
from: '/Users/iamstarkov/projects/es-deps-resolved/fixtures/index.js' },
{ requested: 'pkg-extra', resolved: null,
from: '/Users/iamstarkov/projects/es-deps-resolved/fixtures/index.js' } ] */
esDepsResolved(path.join(__dirname, './fixtures-unexistent'))
.catch(reason => console.error(reason)); // new Error("Can't find and open `./fixtures-unexistent`")
Returns Promise which resolved to Array[Object]
:
Array[Object {
requested: String,
from: String,
resolved: String | null /* `null` if dependency is not resolvable */
}]
Required
Type: String
Absolute path.
- es-deps — ECMAScript 2015+/CommonJS module dependencies array
- es-deps-from-string — ECMAScript 2015+/CommonJS module dependencies array from string
- es-dep-unit — Constructor for ECMAScript 2015+/CommonJS dependency unit
Object { requested, from, resolved }
- es-deps-deep — ECMAScript 2015+/CommonJS module dependencies resolved in depth
- es-dep-kit — ECMAScript 2015+/CommonJS module dependencies helpers kit
MIT © Vladimir Starkov