es-deps-from-string
v1.0.6
Published
ECMAScript 2015+/CommonJS module dependencies array from string
Downloads
6
Maintainers
Readme
es-deps-from-string
ECMAScript 2015+/CommonJS module dependencies array from string
This package handles es2015+ modules, and 'cause CommonJS won't go away anytime soon, it also
takes care of non-dynamic require
s.
Install
npm install --save es-deps-from-string
Usage
import esDepsFromString from 'es-deps-from-string';
const input = `
// es2015+ modules
import out from 'out';
import local from './local';
console.log('modules');
// CommonJS modules
var qName = require('q');
var fsName = require('fs');
var localName = require('./local-cjs');
var n = 1;
require('yo' + 1); // dynamic requires wont work
require('globalImport');
console.log('cjs');`;
esDepsFromString(input); /* [
'out', './local',
'q', 'fs', './local-cjs', 'globalImport',
] */
API
esDepsFromString(input)
// esDepsFromString :: String -> Array[String]
input
Required
Type: String
Your JavaScript code.
Related
- es-deps — ECMAScript 2015+/CommonJS module dependencies array
- es-deps-resolved — ECMAScript 2015+/CommonJS module dependencies resolved array
- 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
License
MIT © Vladimir Starkov