find ES module dependencies
input.js:
import xyz from 'xyz'
import 'a'
require('b')
export default function d () {}
export { d as c }
log.js:
var detective = require('detective-esm')
var fs = require('fs')
console.log(detective(
fs.readFileSync('./input.js')
))
$ node log.js
{ strings: [ 'xyz', 'a' ],
expressions: [],
imports: [ { from: 'xyz', import: 'default', as: 'xyz' } ],
exports: [ { export: 'd', as: 'default' }, { export: 'd', as: 'c' } ] }
npm install detective-esm
var detectiveEsm = require('detective-esm')